[Ipopt] success building Matlab interface on Mac OS X

Ray Zimmerman rz10 at cornell.edu
Wed Oct 12 11:59:13 EDT 2011


I was finally able to successfully build Ipopt and the Matlab MEX interface (both 32-bit and 64-bit versions) on Mac OS X 10.6.8 (Snow Leopard). This is for the MUMPS linear solver ... next step is to try with Pardiso or something. Below are the details of what I did, in case it's helpful to anyone else.

This is for Mac OS X 10.6.8 with the dev tools from XCode 3.2.6, using Matlab R2011b for the 64-bit build and R2010a for the 32-bit build.

1. Install wget.
   (I used wget-1.12 from http://www.merenbach.com/software/wget)

2. Install gfortran
   (I used gfortran-lion-5666-3.pkg from http://r.research.att.com/tools/)

3. Download Ipopt and set up build environment.
   cd ~/build (this is where I build things)
   tar zxvf ~/Downloads/Ipopt-3.10.1.tgz
   cd ~/build/Ipopt-3.10.1/ThirdParty/Mumps/
   ./get.Mumps
   cd ~/build/Ipopt-3.10.1/ThirdParty/Metis/
   ./get.Metis
   cd ~/build/Ipopt-3.10.1
   mkdir build32
   mkdir build64

4. Build 64-bit Ipopt
   cd ~/build/Ipopt-3.10.1/build64
   ../configure --with-blas="-framework vecLib" \
      --with-lapack="-framework vecLib" F77=gfortran \
      FFLAGS="-fexceptions -m64 -fbackslash" \
      CFLAGS="-fno-common -no-cpp-precomp -fexceptions -arch x86_64 -m64" \
      CXXFLAGS="-fno-common -no-cpp-precomp -fexceptions -arch x86_64 -m64" \
      -disable-shared
   make test
   make install

5. Set up 64-bit Matlab MEX environment
   In Matlab R2011b:
      mex -setup (select option 1)
   edit 'maci64' section of ~/.matlab/R2011b/mexopts.sh:
      change 'libgfortran.dylib' to 'libgfortran.a' in FC_LIBDIR line
         (my gfortran includes only static libs, besides I want this
          to work on machines without gfortran installed)
      remove '-Wl,-syslibroot,$SDKROOT' from LDFLAGS line
         (otherwise it can't find gfortran libraries)
      add line:
          LDFLAGS="$LDFLAGS -framework vecLib"

6. Build 64-bit MEX file
   cd ~/build/Ipopt-3.10.1/build64/Ipopt/contrib/MatlabInterface/src
   edit Makefile, make the following changes:
      MATLAB_HOME = /Applications/MATLAB_R2011b.app
      MEXSUFFIX   = mexmaci64
      delete from LIBS line:
         all instances of '-framework vecLib' (4 instances in my case)
            (this is added in mexopts.sh now)
         -L/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../..
            (this causes it to find the wrong libmx.dylib
             the one in /usr/lib rather than the Matlab one)
   make
   cp ipopt.mexmaci64 ~/Documents/MATLAB (or somewhere in your Matlab path)

7. Build 32-bit Ipopt
   cd ~/build/Ipopt-3.10.1/build32
   ../configure --with-blas="-framework vecLib" \
      --with-lapack="-framework vecLib" F77=gfortran \
      FFLAGS="-fexceptions -m32 -fbackslash" \
      CFLAGS="-fno-common -no-cpp-precomp -fexceptions -arch i386 -m32" \
      CXXFLAGS="-fno-common -no-cpp-precomp -fexceptions -arch i386 -m32" \
      -disable-shared
   make test
   make install

8. Set up 32-bit Matlab MEX environment
   In Matlab R2010a:
      mex -setup (select option 1)
   edit 'maci' section of ~/.matlab/R2010a/mexopts.sh:
      (same as in step 5)
      change 'libgfortran.dylib' to 'libgfortran.a' in FC_LIBDIR line
      remove '-Wl,-syslibroot,$SDKROOT' from LDFLAGS line
      add line:
          LDFLAGS="$LDFLAGS -framework vecLib"

9. Build 32-bit MEX file
   cd ~/build/Ipopt-3.10.1/build32/Ipopt/contrib/MatlabInterface/src
   edit Makefile, make the following changes:
      MATLAB_HOME = /Applications/MATLAB_R2010a.app
      MEXSUFFIX   = mexmaci
      delete from LIBS line:
         (same as in step 6)
         all instances of '-framework vecLib'
         -L/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../..
   make
   cp ipopt.mexmaci ~/Documents/MATLAB (or somewhere in your Matlab path)


Hopefully, this will be a help to others who want to build Ipopt and the Matlab interface for Mac.

-- 
Ray Zimmerman
Senior Research Associate
419A Warren Hall, Cornell University, Ithaca, NY 14853
phone: (607) 255-9645




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/ipopt/attachments/20111012/46d16a71/attachment.html>


More information about the Ipopt mailing list