Instructions on how to compile the MATLAB interface of Ipopt (MEX) in Windows. This procedure worked (9/8/2011) on Windows 7 64 bit with a MATLAB 32 bit mex target. If you are not familiar with Linux: to untar files in MinGw use the command "tar -xvf " or "tar -zxvf " if the file is a gz archive (or you can use 7-zip downloadable from http://www.7-zip.org/) Following these steps I eventually got a working ipopt.mexw32 (of course there might be alternative ways to obtain the same results): 1) Download MinGw (32 bit in my case) from the website http://www.mingw.org/ The latest release Graphical User Interface Installer should be available on the page http://www.mingw.org/wiki/Getting_Started (I used the installer file mingw-get-inst-20110802.exe) Install all the components if you do not have space limitaions 2) Download the wget port for MinGw from http://sourceforge.net/projects/mingw/files/mingwPORT/Current%20Releases/ untar the archive and copy the file wget.exe to the folder /bin in the MinGw installation folder (I used wget-1.9.1-mingwPORT.tar) 3) Download ipopt from the website https://projects.coin-or.org/Ipopt (I used Ipopt-3.10.0.tgz which you can find at http://www.coin-or.org/download/source/Ipopt/) move the archive to the home directory of your MinGw installation (in my case it was C:/msys/1.0/home/) untar the archive and rename the folder Ipopt-x.y.z as CoinIpopt (to have a standard name) 4) If you haven't done it yet, open a MinGw shell (from the "All Programs/MinGw/" folder in the Start menu) and go to the folder CoinIpopt using the command cd CoinIpopt 5) Install the Third Party software following the instructions in the files INSTALL.XXX in all the folders in CoinIpopt/ThirdParty/ for ASL, Blas, Lapack and Mumps just execute the following commands (each command is separated by a semi-colon, and the whole line may be executed at once) cd ThirdParty/ASL;./get.ASL;cd ../Blas;./get.Blas;cd ../Lapack;./get.Lapack;cd ../Mumps;./get.Mumps;cd ../.. (the last command is to return to the CoinIpopt/ folder) For Metis I had to download the file metis-4.0.3.tar.gz from http://glaros.dtc.umn.edu/gkhome/fsroot/sw/metis/OLD () as the release 5.0 did not work straightaway, extract the archive, rename the extracted folder (metis.4.0.3) as metis-4.0 and move it to the folder CoinIpopt/ThirdParty/Metis/ This can be done by running the following commands: wget http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/OLD/metis-4.0.3.tar.gz tar -zxvf metis-4.0.3.tar.gz mv metis-4.0.3 ThirdParty/Metis/metis-4.0 For HSL I downloaded the packages MC19 and MA27 (double precision) from http://www.hsl.rl.ac.uk/archive/ you will have to register to get access. Save the source code to the corresponding files mc19ad.f and ma27ad.f in the folder CoinIpopt/ThirdParty/HSL As an alernative to the linear sparse solver MA27 you can use the MA57, which can be downloaded after request from http://www.hsl.rl.ac.uk/catalogue/ In the folder src/ in the m57-3.7.0.tar.gz archive (with dependencies) you should find the files "ma57d.f" "ddepd.f" . Rename "ma57d.f" as "ma57ad.f" and append all the code in "ddepd.f" to to "ma57ad.f", then move "ma57ad.f" to the folder CoinIpopt/ThirdParty/HSL 6) In the CoinIpopt folder, create a folder build/ and enter it, then run the configure command for Ipopt (these operations can be executed running the following commands) cd CoinIpopt; mkdir build;cd build ../configure --enable-doscompile --disable-shared –-enable-static ADD_CXXFLAGS="-fexceptions" ADD_CFLAGS="-fexceptions" ADD_FFLAGS="-fexceptions" This may take some time to complete ~15 mins possibly. 7) Compile Ipopt running the following commands in the build folder make;make test;make install;cd .. (the last command is to return to the CoinIpopt/ folder) This may take some time to complete >1 hour possibly. The resulting executable should be in the folder CoinIpopt/build/bin and can be tested running the following commands cd ../Ipopt/test;../../build/bin/ipopt mytoy;cd ../.. (the last command is to return to the CoinIpopt/ folder) 8) Add the folder "C:/MynGw/bin" to the MATLAB path (this can be done in MATLAB using the option "Set Path.." in the "File" menu) (you can also save the updated path for future instances of MATLAB) 9) Download "gnumex-2.04.zip" from http://sourceforge.net/projects/gnumex/ Extract the archive to the MATLAB startup folder and add the folder gnumex/ to the MATLAB path In MATLAB, run gnumex (a GUI is shown), check that all the fields are correct and create the new "mexopts.bat" file by pressing the "Make Opts" button in the GUI (for further reference on gnumex read http://gnumex.sourceforge.net/#matlab_steps) (you might want to save a copy of the old "mexopts.bat" before creating the new one) This step will set gcc as the standard compiler for the mex files; if you want to go back to another compiler run in MATLAB "mex -setup" (at this stage you should not be able to include some libraries such as "math.h", but it can be done by modifying the compiler and linker commands) 10) Modify the Makefile in CoinIpopt/build/Ipopt/contrib/MatlabInterface/src/: set MATLAB_HOME to your MATLAB (32 bit) installation folder in my case "MATLAB_HOME = /c/MATLAB/R2010bx86/" MEXSUFFIX = mexw32 MEX = $(MATLAB_HOME)/sys/perl/win32/bin/perl.exe $(MATLAB_HOME)/bin/mex.pl remove the flag "-cxx" from "MEXFLAGS" 11) Modify the "mexopts.bat" created by gnumex: set GM_MEXLANG=cxx set GM_ADD_LIBS=-llibmx -llibmex -llibmat -Lc:/msys/1.0/home/CoinIpopt/build/lib/coin -Lc:/msys/1.0/home/CoinIpopt/build/lib -lipopt -lcoinhsl -lcoinmumps -lcoinlapack -lcoinblas -lcoinmetis -Lc:/MinGW/lib -LC:/MinGW/lib -Lc:/mingw/bin/../lib/gcc/mingw32/4.5.2 -Lc:/mingw/bin/../lib/gcc -Lc:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/lib -Lc:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../.. -L/mingw/lib -lgfortran -lmingw32 -lgcc_s -lmoldname -lmingwex -lmsvcrt -luser32 -lkernel32 -ladvapi32 -lshell32 -lpthread -lm set COMPILER=g++ 12) Compile the Ipopt MEX file running the following commands in MinGw cd build/Ipopt/contrib/MatlabInterface/src/ make The file ipopt.mexw32 should be in the folder CoinIpopt/build/Ipopt/contrib/MatlabInterface/src/ Add this file to the MATLAB path 12b) If 12) doesn't work try rename all the libraries in build/lic/coin and build/lic/coin/ThirdParty from lib*.a to l*.lib and then to execute this command from MATLAB in the folder build/Ipopt/contrib/MatlabInterface/src/ : mex ipopt.o matlabexception.o matlabfunctionhandle.o matlabjournal.o iterate.o ipoptoptions.o options.o sparsematrix.o callbackfunctions.o matlabinfo.o matlabprogram.o C:\msys\1.0\home\Ipopt-3.9.3\build\lib\coin\lipopt.lib C:\msys\1.0\home\Ipopt-3.9.3\build\lib\coin\lipoptamplinterface.lib C:\msys\1.0\home\Ipopt-3.9.3\build\lib\coin\ThirdParty\lcoinmumps.lib C:\msys\1.0\home\Ipopt-3.9.3\build\lib\coin\ThirdParty\lcoinmetis.lib C:\msys\1.0\home\Ipopt-3.9.3\build\lib\coin\ThirdParty\lcoinblas.lib C:\msys\1.0\home\Ipopt-3.9.3\build\lib\coin\ThirdParty\lcoinhsl.lib C:\msys\1.0\home\Ipopt-3.9.3\build\lib\coin\ThirdParty\lcoinmetis.lib C:\msys\1.0\home\Ipopt-3.9.3\build\lib\coin\ThirdParty\lcoinlapack.lib C:\msys\1.0\home\Ipopt-3.9.3\build\lib\coin\ThirdParty\lcoinblas.lib -LC:\Users\Giacomo\AppData\Roaming\MATHWO~1\MATLAB\R2010b\gnumex -LC:\MinGW\lib\gcc\mingw32\4.5.2 -LC:\MinGW\lib\gcc -LC:\MinGW\mingw32\lib -LC:\MinGW\lib -LC:\msys\1.0\home\Ipopt-3.9.3\build\lib\coin\ThirdParty -LC:\msys\1.0\home\Ipopt-3.9.3\build\lib\coin Hope this was helpful, I will try to provide a MATLAB script to test the ipopt MEX function