Compilation Hints

Here we collect tips and tricks for compiling Ipopt. We invite everybody to add to this page, particularly when you found a workaround for a difficult setting (if you don't mind, it would be nice if you could leave contact information in case someone has problems with your suggestions).

Please read also the COIN-OR current issues page for hints on frequent problems.


Windows with Intel Suite

General Notes

  • These instructions give hints on a native build with intel compilers, cmake (where possible), and decoupled libraries.
  • It is assumed that you will build and link all dependent libraries separately.
  • Assumed you have Intel Fortran and C++ version 11.0 or above with the MKL. Also, Visual Studio.
  • These were tested with MPICH2 for windows.
  • In the attached CMake files, they will refer to many environment variables such as $ENV{ETK_BINARIES} . Sorry, I didn't have time to decouple all of this from the main build environment for my server. So replace as necessary when you read through.
  • You will need to read up a little on CMake to understand their makefiles to change include directories, etc. But it is pretty easy. The attached batch files to generate visual studio files, nmake files for release/debug, etc. set the proper variables before calling CMake.

Compiling HSL Routines

  • See attached CMakeLists.txt to compile
  • Otherwise, you will just need to download the appropriate HSL Fortran libraries on your own and compile
  • Also note that there is a cmake file to replace the Windows ifort that comes with CMake. The problem is that the default runtime library used by the FOrtran compiler in CMake is different from that used in everything else. This change modifies the default static .lib generation to use /MD and /MDd instead of /MT and /MTd. All other CMake builds default to these runtime libraries.

Compiling Sequential and Parallel Mumps

  • The easiest way to compile is to use WinMumps?, which generates visual studio projects.
  • I didn't rewrite a cmake for these, since they seemed to work well.
  • You will see in the instructions that there are ways to generate either a set of both projects at once, or them individually. Do the individual sequential/parallel builds
  • The instructions were very clear, but it creates a huge number of visual studio files. You will need to go through them individually for the sequential and fortran builds. Note that you really only need to compile the "dmumps..." versions for Ipopt.
  • When you open up one of the projects, you will want to:
    • Convert the Project to use Intel C++ through the menus
    • For the debug build, change the output lib name to have a "_d" after it so you can keep both copies in the same binaries directory
    • You can doublecheck that the runtime library is "/MD" and /MDd
  • I compiled it with metis (see winmumps instructions), but I doubt this would change anything.

Compiling Metis

  • I think I just threw the downloaded .c files into a directory and used the CMakeLists.txt and batch files to generate the libs.
  • My rough notes also suggest that I removed the #include <strings.h> in metis.h to get it to compile.

Compiling Ipopt

  • I reorganized the Ipopt source/headers a little. First, I separated the .h from the .cpp so that I had a header include folder for my sample code. I put these into a single folder because it seemed to be the easiest way to get it to compile.
  • Next, I collapsed the .cpp folders into a single folder. The way they include headers is by #include "IpSmartPtr.hpp" without using <> or relative paths to headers, so you need to make sure that you can get those to compile.
  • Next, I turned off the hardcoded #define for all of the linear solvers in IpoptConfig?.h. The goal there was to make it flexible to do different builds of the library from different settings.
  • There may also have been a COIN_USE_F2C define that I had to turn off, but I didn't take very good notes on it.
  • Last, ran the attached CMakelists.txt to generate a few different versions of the library.
  • You will also see that I have an "include" directory for the COIN in the CMakelists, which is where I setup the headers. You would need to change that to match your build as required.
  • CMakelists.txt and IpoptConfig?.h are attached.

Compiling/Linking an Example

  • I took the standard example. I don't think that I made any changes except to change the header pathsto be consistent with my setup.
  • The CMakelists.txt to build all of the permutations is attached. As are a bunch of batch files.
    • Sorry, but this CMakelists is using a general purpose module I wrote for my projects. The module sets up the right include/link directories and creates a list of libraries included depending on the different settings.
    • Besides the debug vs. optimized setting, there is also a USE_MPI which is set in the CMakeCache either directly or through the batch files. This changes the libraries that are linked in.
    • I should have a USE_MUMPS option which links to the appropriate version of the library and sets the appropriate #define when compiling, but I haven't needed it yet.
    • If you try to rewrite parts of this or add it directly to the test file, you will need to:
      • Add in the equivalent of $ENV{ETK_LIBRARIES}/coin to the include_directories()
      • Add in the location of all of your generated .lib files from above to the link_directories
      • Add in the right libraries depending on if it is a debug/release and mpi vs. nonmpi build. YOu can see the appropriate libraries in the if(WIN32) section. It should be clear which ones to skip since they will be in the "other" section.
      • Set the appropriate HAVE_MA27 HAVE_MC19 HAVE_MUMPS COIN_HAS_MUMPS in the compile definitions.

Windows with Visual Studio 2005/2008 and Intel Fortran Compiler

Contributed by Chuck Teeter on 2009-07-16 (chuck.teeter@…)

Last updated on 2010-04-27

General Notes

  • If you wish to use Ipopt as a Windows DLL and do not want to build it yourself, you can download the binary (win32 and/or x64) from the Ipopt download area. This DLL incorporates the MUMPS linear solver. If you then use this DLL for your own optimization projects, refer to the section below more details surrounding its proper use (ie, use the IpoptApplicationFactory?() method).
  • The Ipopt distribution includes two different Visual Studio solutions. The first, located under the 'v8' folder, builds Ipopt as a static library (libIpopt.lib). The main assumption here is that all projects in the solution are built with C/C++ source files, so no FORTRAN compiler is required, unless you want to build MUMPS. However, all other third-party FORTRAN source code(like MA27) must first be converted to C using f2c.

  • The second Visual Studio solution, located under the 'v8-ifort' folder, builds Ipopt as a Windows DLL, and is meant to incorporate MUMPS as the default linear solver. The 'v8-ifort' solution also assumes that you will be using the Intel FORTRAN compiler to build MUMPS and any HSL code (MA27 or MA57) code that you might be using as well. If you plan to use Ipopt with the AIMMS modeling system, it is recommended that you use the 'v8-ifort' solution, since it allows you to select multiple linear solvers at runtime (via AIMMS) without having to re-compile the solution. Note that if you plan to build Ipopt as a DLL, you should use the IpoptApplicationFactory?() method exported by the DLL to obtain an IpoptApplication? pointer, rather than using the new operator. This call looks something like this:

SmartPtr?<IpoptApplication?> app = IpoptApplicationFactory?();

Once this is done, you can call the methods of the IpoptApplication? object as you normally would.

  • The two Visual Studio solutions enable you to build Ipopt for both Win32 and x64 platforms.
  • The instructions below assume that you use the Visual Studio 2005/2008 IDE to build C/C++ projects and that you have the Intel Fortran Compiler, version 9 or later. For my builds, I used Visual Studio 2008 Standard Edition and version 11.1 of the Intel Fortran Compiler. I have also successfully used version 11.1 of the Intel C++ compiler with Visual Studio for my Ipopt builds.

  • All of my Ipopt-related projects were built using /MT for release builds and /MTd for debug builds. Mixing different versions of runtime libraries will create all kinds of problems at the LINK stage - make sure that you are consistent with your choice(s).
  • The Visual Studio solution that comes with the Ipopt distribution was created using Visual Studio 2005. If you are using Visual Studio 2008, the solution can be converted to VS 2008 format via a conversion wizard when it is first loaded.

Compiling HSL Routines ('v8' Solution)

  • I was able to compile the HSL routines (MA27/MC19) by first running f2c.exe on the source files per the included Ipopt documentation.
  • Resist any temptation you might have to convert 4 byte REALs to 8 byte DOUBLEs after running f2c. Ipopt assumes that no changes to the calling interface have been made by developers.
  • I get a couple of compiler warnings when building MA27 and MC19, having to do with operator precedence and possible data loss when converting from 'double or 'doublereal' to 'real'. These can safely be ignored.

Compiling Sequential Mumps ('v8' Solution)

  • I built Sequential Mumps using WinMumps?, and it worked great. Though I chose not to do so, building Parallel Mumps is a very similar process. The only thing to keep in mind is that your directory structure must be set correctly for the Python script to work properly. Follow these general steps:
  • Create a folder 'MUMPS' under your Visual Studio\Projects directory.
  • Unzip the MUMPS source into this directory. This will create a new directory 'MUMPS_4.8.4' under folder 'MUMPS'.
  • Unzip the WinMumps? distribution into the 'MUMPS' folder. This will create a new directory 'WinMumps?-4.8' under folder 'MUMPS'.
  • In a DOS window, navigate to the 'WinMumps?-4.8' directory and execute the Python script, substituting '4.8.4' (or most recent version) for '4.8.0' in the Python command string documented in the readme.html file. Execution of this script will create the required VC and Fortran project files in the 'MUMPS' folder.
  • For Sequential MUMPS, the projects of interest are: dmumps_c, dmumps_fortran, libseq_c, libseq_fortran, mumps_common_c, and pord_c. Each of these projects results in the building of a static library. Each of these libraries must then be linked with the Ipopt project. The dmumps_fortran library is the only one which calls into Metis.
  • I modified the resulting projects to use the same runtime libraries I had already selected for other libraries.
  • You may receive some compiler warnings related to structure alignment. These can safely be ignored.

Compiling Metis ('v8' Solution)

  • I collected all of the Metis source files into a single directory and created a single VC static library project to build them.
  • In order to get Metis to compile, I had to make a few minor changes to the source code:
  • I had to include a dummy "strings.h" line in the header file "metis.h" to satisfy the compiler.
  • In file "proto.h", I had to uncomment one of the function declarations in the section under /* util.c */. However, I don't remember now which one it was.
  • I also had to define the symbol "_VC_", to prevent the inclusion of functions srand48() and drand48() which are not supported in Windows.
  • Expect a lot of compiler warnings, especially C4244: 'Conversion from 'double' to 'idxtype', possible loss of data'. I get about 70 such warnings for both release and debug builds.

Compiling Ipopt with MUMPS ('v8' Solution)

  • I had no problem compiling Ipopt with the default MA27 linear solver, but building it with MUMPS was a little trickier.
  • First, the IpOptConfig?.h file must be modified. The symbol 'COIN_HAS_MUMPS' must be added and defined or the MUMPS interface code will not be compiled. Note that the existing 'HAVE_MUMPS' symbol in IpOptConfig?.h is not referenced anywhere else in the Ipopt code, and will not be used for this purpose.
  • Second, make sure that you include the source files "IpMumpSolverInterface?.cpp" and "IpTSymDependencyDetector.cpp" in your project or you will get 'Unresolved External' LINK errors when building. The default Ipopt project that comes with the source distribution does not currently incorporate these files.
  • Finally, you will need to add some additional include directories for the definition of MUMPS symbols: MUMPS_4.8.4\include and MUMPS_4.8.4\libseq (for 'mpi.h').

Compiling Ipopt using MinGW on Windows - Using GNU-GCC and gfortran

This allows us to use MA57 and/or MUMPS that require F90

by Rodrigo Lopez-Negrete (rln@…) Jun. 22, 2011

UPDATE: The following instructions I've tested using the latest MinGW. This comes with GNU-GCC v4.5.2 and it comes with Gfortran so there is no need to get thirdparty compilers as in the previous set of instructions. See further down to find the old method, if you have access to MinGW-5.1.6. Otherwise, the following instructions will hopefully work for you. I've tested this in a Windows XP machine.

In my case I got some errors during compilation. It seems that the configure script is adding a few extra spaces when specifying library paths. If you see these errors, please download the attached script and execute it in your build folder.

  • Download MinGW and install (make sure you also install gfortran)
  • Download Ipopt tarball and follow the instructions to get Thirdparty software
  • Configure, compile and install Ipopt. If you get errors during compilation that are related to library paths you may need to download the attached script and execute it in your build folder. In my case I created a build directory inside the Ipopt folder. Thus I configured the build using
    1. $../configure -C --enable-doscompile --disable-shared –enable-static You may need to change this if you want the Matlab inteface. See below.
    2. Build (if you have multiple cores you can speed this up adding the flag -j#cores, eg make -j2 for two cores)
    3. $ make && make test
    4. If no errors are found: $ make install
    5. If you get errors during compilation copy the file to your build folder and execute it:
      • $ chmod 755
      • $./
      • $ make && make test && make install
  • If you had the ASL files this also generates the AMPL executable. Moreover, if you link to this library or use the AMPL executable, and you need to execute them in other PC's (that don't have your installation of MinGW) you also need to copy and share the following libraries: libgcc_s_dw2-1.dll, libpthread-2.dll, libgfortran-3.dll, and libstdc++-6.dll.

Quick fix script

To use the script, copy the following code into a text file called, change permissions so it is executable, and run it in the build folder. This should fix the added whitespace in the library path specifications.


files=`find . -name 'Makefile'`
echo $files
for f in $files
  echo 'Fixing ' $f
  sed -e 's#-Lc\ /m#-Lc/m#g' $f > $f.temp
  mv $f.temp $f

files=`find . -name ''`
echo $files
for f in $files
  echo 'Fixing ' $f
  sed -e 's#-Lc\ /m#-L/c/m#g' $f > $f.temp
  mv $f.temp $f

Compiling the Matlab Interface using MinGW on Windows - With GNU-GCC and gfortran

This allows us to use MA57 and/or MUMPS that require F90

Read this before using these steps!

Note that the following instruction can be used with both the old and new versions of MinGW. However, there are some messages in the mailing list that suggest that it is no longer possible to do so using the old version. However, if you have it and wish to try it, see below for instructions on how to first get the IPOPT executables and libraries using MinGW-5.1.6. Otherwise, follow the instructions above for the new version of MinGW, and then the following instructions to generate the Matlab interface. I've tested this in a Windows XP machine with Matlab 2009a.

by Rodrigo Lopez-Negrete (rln@…) Jun. 22, 2011

Note that almost no support is given to windows users for compiling this interface. Therefore, what follows is based on my experience building it, and, unfortunately, these instructions may not work for everyone.

First you will need MinGW and gnumex, please refer to the Matlab Interface wiki for more information. Also, remember to add c:\mingw\bin to your path before compiling the Matlab Interface.

When compiling Ipopt I used the following configuration flags. These may not be necessary, however I haven't tested other combinations yet.

 $ ../configure --enable-doscompile --disable-shared –-enable-static \
                ADD_CXXFLAGS="-fexceptions" ADD_CFLAGS="-fexceptions" ADD_FFLAGS="-fexceptions" 

Once Ipopt has been compiled, and you have generated the libraries and from gnumex we can proceed.

  • First copy the mexopts.bat file generated by gnumex in $IPOPT/build/Ipopt/contrib/Matlabinterface/src
  • Edit the makefile so that the following variables are set as follows.

    Note that in my case, I'm using a 32 bit computer, and I have Matlab 2009a, but you should set this according to your CPU architecture and Matlab version.
    1. MATLAB_HOME = /c/PROGRA~1/MATLAB/R2009a/
    2. MEXSUFFIX = mexw32
    3. MEX = $(MATLAB_HOME)/sys/perl/win32/bin/perl.exe $(MATLAB_HOME)/bin/
    4. remove the -cxx flag from MEXFLAGS
  • Edit the file that you previously copied so that the following variables are set as follows
    1. set GM_MEXLANG=cxx
    2. set GM_ADD_LIBS=-llibmx -llibmex -llibmat -LC:/MinGW/msys/1.0/home/testnew/IPOPT_t_sm/build/lib -lipopt -lcoinmumps -lpthread -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 -lgfortranbegin -lgfortran -lmingw32 -lmoldname -lmingwex -lmsvcrt -luser32 -lkernel32 -ladvapi32 -lshell32 -lcoinmetis -lcoinblas -lcoinhsl -lcoinlapack -lcoinblas -lm

      Note that the first path is the full path to your compiled Ipopt library, and you should change this according to your own settings. The same goes for the paths related to the compilers, in case you do not have the same version (i.e., in this case 4.5.2).
    3. set COMPILER=g++
  • Now you can type make so that the interface is generated.
  • Moreover, if you need to execute this in other PC's (that don't have your installation of MinGW) you also need to copy and share the following libraries: libgcc_s_dw2-1.dll, libpthread-2.dll, libgfortran-3.dll, and libstdc++-6.dll.

OLD VERSION to Compile Ipopt using MinGW on Windows - Using GNU-GCC and gfortran

This allows us to use MA57 and/or MUMPS that require F90

This is the old method that requires MinGW-5.1.6.

Note that recent messages in the mailing list show that these steps only work with previous versions of MinGW. When I first wrote this I installed MinGW using their MinGW-5.1.6.exe installer. It seems that when using the new mingw-get-inst*.exe installer, the following steps don't work properly. My suggestion is to use MinGW-5.1.6.exe if you can find it. Otherwise, in the mailing list there are some that have been able to compile using the newer version of MinGW.

by Rodrigo Lopez-Negrete (rln@…) Apr. 20, 2010

  • Download MinGW and install
  • Download MSys and install
  • Download MinGW/TDM compilers, version 4.3.2-tdm-2 (I've tried other versions, and they don't work)
    1. gcc-4.3.2-tdm-2-core.tar.gz
    2. gcc-4.3.2-tdm-2-g++.tar.gz
    3. gcc-4.3.2-tdm-2-fortran.tar.gz
  • Extract the compiler files with
    1. $ tar xzf gcc-4.3.2-tdm-2-core.tar.gz -C /mingw
    2. $ tar xzf gcc-4.3.2-tdm-2-g++.tar.gz -C /mingw
    3. $ tar xzf gcc-4.3.2-tdm-2-fortran.tar.gz -C /mingw
  • Backup libstdc++* just in case
    1. $ cp /mingw/lib/libstdc++.a /mingw/lib/libstdc++.a.orig
    2. $ cp /mingw/lib/ /mingw/lib/
  • Copy libstdc++.* to /mingw/lib
    1. $ cp /mingw/lib/gcc/mingw32/4.3.2/libstdc++* /mingw/lib/
  • Download Ipopt tarball and follow the instructions to get Thirdparty software, and to compile it.
  • In my case I created a build directory inside the Ipopt folder. Thus I configured the build using
    1. $ ../configure -C --enable-doscompile --disable-shared --enable-static
  • Build (if you have multiple cores you can speed this up adding the flag -j#cores, eg make -j2 for two cores)
    1. $ make && make test
    2. If no errors are found: $ make install

If you had the ASL files this also generates the AMPL executable. Moreover, if you link to this library or use the AMPL executable, and you need to execute them in other PC's (that don't have your installation of MinGW) you also need to copy the pthreadGC2.dll.

Mac OS X

Nov 19, 2013 Dominique Orban reported that there is now a formula for IPOPT as part of Homebrew/Science. Installing is a matter of saying:

	brew tap homebrew/science   # if not already done
	brew install ipopt [--with-openblas]

Nov 7, 2011 Ipopt on Mac OS X contains detailed Mac OS X build notes, including Matlab interface, by Ray Zimmerman (rz10@…).

by Rodrigo Lopez-Negrete (rln@…) Aug. 15, 2010

These are the steps I use for compiling Ipopt on my Macbook pro. I've got an Intel processor, and I'm using Mac OS X Snowleopard 10.6.4. Unfortunately, these instructions may not work for older systems.

  1. Install XCode. This is included in the Mac OS installation disks or it can be downloaded.
  2. Install the GNU GCC compilers from Choose gcc-snwleo-intel-bin.tar.gz, and follow the instructions in the site.

2(b). Make sure you install both the gcc and gfortran packages, as the versions of both compilers need to match for a successful compilation.

  1. Download Ipopt and the required Thirdparty packages.
  2. Create a build directory, cd into it, and configure Ipopt using:
        $../configure -C  CC="gcc -m32" CXX="g++ -m32" F77="gfortran -m32" \
          ADD_CXXFLAGS="-mmacosx-version-min=10.5 -fno-common -fexceptions -fPIC" \
          ADD_CFLAGS="-mmacosx-version-min=10.5 -fno-common -fexceptions -fPIC" \
          ADD_FFLAGS="-mmacosx-version-min=10.5 -fPIC -fno-common" \
  1. Now you can run make, make test, make install as needed.


On some NEC/SuperUX systems, at appears necessary to add the C++ compiler flag -Tnoauto-local

Calling Ipopt from .NET code

by Anders Gustafsson, anders at cureos dot com, December 20, 2011.

I have developed a small and simple C# interface to Ipopt and made it available under the Eclipse Public License on Github, If the code is contained in a class library, the Ipopt interface can be called from practically any .NET language. The interface is applicable to .NET Framework 2.0 or later, or corresponding Mono versions.

Pre-compiled .NET class libraries are contained in a zip archive, which can be downloaded from here: Source code can be obtained here:

To successfully run an application that is calling the C# Ipopt interface, a dynamic linked library of Ipopt is additionally required. Pre-compiled libraries can be downloaded from the Ipopt directory of the COIN-OR binary distribution project.

Download binaries suitable for your platform, unpack the compressed Ipopt binary archive, from the folder .\lib\PLATFORM\release (where PLATFORM is win32 or x64) copy the Ipopt*.dll files and place them alongside the Ipopt application or in a folder that is accessible from the system path.

To use the C# interface in your own code, simply copy the files Ipopt*.cs to your class library. (Potentially, you may need to edit the references to Ipopt39.)

To demonstrate how the C# Ipopt interface can be applied, the source code from the Github project page contains a few examples. There are also batch scripts for building a class library and applications from the Visual Studio and Mono command prompts. For additional information on how to use csipopt, consult the csipopt wiki:

Last modified 7 years ago Last modified on Mar 13, 2015 2:45:00 AM

Attachments (2)

Download all attachments as: .zip