[Ipopt] summary of how to build Ipopt & Matlab interface on Mac OS X
Ray Zimmerman
rz10 at cornell.edu
Fri Oct 21 11:54:59 EDT 2011
Here is an updated summary of my experience building Ipopt 3.10.1 and the Matlab interface for it on Mac OS X 10.6 Snow Leopard and 10.7 Lion. I believe I have now built all combinations of the following:
OS
S = built on Snow Leopard (10.6.8), dev tools from Xcode 3.2.6
L = built on Lion (10.7.2), dev tools from Xcode 4.2
Linear Solver
M = MUMPS
H = HSL MA57
Blas/Lapack
N = Netlib BLAS/LAPACK
A = native OS X optimized BLAS/LAPACK included in Accelerate/vecLib framework [1]
32 vs 64 bit
32 = 32-bit build (with Matlab R2011b)
64 = 64-bit build (with Matlab R2010a)
For shorthand, I'll use the letters above to distinguish between the options in the build instructions below.
While I have been able to build all combinations above, it appears there is an issue with the BLAS/LAPACK in Lion's Accelerate/vecLib framework [2] that causes Ipopt to frequently fail. So the only binaries that I could get to work reliably on Lion were those built (on Snow Leopard or Lion) with the Netlib BLAS.
1. Install wget.
I used wget-1.12 from http://www.merenbach.com/software/wget
2. Install gfortran (I used the ones from http://r.research.att.com/tools/)
S : gfortran-42-5664.pkg (http://r.research.att.com/gfortran-42-5664.pkg)
L : gfortran-lion-5666-3.pkg (http://r.research.att.com/gfortran-lion-5666-3.pkg)
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/Metis/
./get.Metis
cd ~/build/Ipopt-3.10.1
mkdir build64
mkdir build32
4. Choose and set up BLAS
N - download Netlib BLAS/LAPACK
cd ~/build/Ipopt-3.10.1/ThirdParty/Blas/
./get.Blas
cd ~/build/Ipopt-3.10.1/ThirdParty/Lapack/
./get.Lapack
A - do nothing
5. Choose and set up linear solver
M - get Mumps
cd ~/build/Ipopt-3.10.1/ThirdParty/Mumps/
./get.Mumps
H - download latest source (coinhsl-2011.10.03.tar.gz) from http://www.hsl.rl.ac.uk/ipopt/
cd ~/build
tar zxvf ~/Downloads/coinhsl-2011.10.03.tar.gz
cd ~/build/coinhsl-2011.10.03
cp mc19/mc19d.f ../Ipopt-3.10.1/ThirdParty/HSL/mc19ad.f
cat ma57/ma57d.f common/deps.f > ../Ipopt-3.10.1/ThirdParty/HSL/ma57ad.f
6. Configure Ipopt build, depends on N vs A and 32 vs 64 bit, so choose the appropriate one:
N64
cd ~/build/Ipopt-3.10.1/build64
../configure --with-blas=BUILD \
--with-lapack=BUILD 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
N32
cd ~/build/Ipopt-3.10.1/build32
../configure --with-blas=BUILD \
--with-lapack=BUILD 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
A64
cd ~/build/Ipopt-3.10.1/build64
../configure --with-blas="-framework Accelerate" \
--with-lapack="" 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
A32
cd ~/build/Ipopt-3.10.1/build32
../configure --with-blas="-framework Accelerate" \
--with-lapack="" 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
7. Build, test and install Ipopt
make
make test
make install
8. Set up Matlab MEX environment (depends on N vs A and 32 vs 64 bit)
N64
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)
N32
in Matlab R2010a:
mex -setup (select option 1 or 2)
edit 'maci' section of ~/.matlab/R2010a/mexopts.sh:
(same as for N64)
A64
same as N64, with following addition to mexopts.sh edit:
add line:
LDFLAGS="$LDFLAGS -framework Accelerate"
A32
same as N32, with following addition to mexopts.sh edit:
add line:
LDFLAGS="$LDFLAGS -framework Accelerate"
9. Build MEX file (depends on N vs A and 32 vs 64 bit)
N64
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 duplicates
-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)
N32
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 N64)
add '-maci' to MEXFLAGS
make
cp ipopt.mexmaci ~/Documents/MATLAB (or somewhere in your Matlab path)
A64
same as N64 with following exception
in LIBS line of Makefile:
delete all instances of '-framework Accelerate'
(this is added in mexopts.sh now)
A32
same as N32 with following exception
in LIBS line of Makefile:
delete all instances of '-framework Accelerate'
Hopefully, this will be a help to others who want to build Ipopt and the Matlab interface for Mac.
[1] Mac OS X includes it's own optimized BLAS and LAPACK libraries in the vecLib framework, which is a sub-component of the Accelerate framework. I believe that using '-framework Accelerate' and '-framework vecLib' has the same effect and can be used interchangeably in this context.
[2] I think this is related to the issue mentioned here <https://github.com/mxcl/homebrew/issues/6649#issuecomment-1666673>.
--
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/20111021/95a5e203/attachment.html>
More information about the Ipopt
mailing list