[Ipopt] help building Matlab interface for Ipopt on Mac

Ray Zimmerman rz10 at cornell.edu
Fri Sep 30 15:08:54 EDT 2011

I've finally gotten back to trying to build Ipopt and the Matlab interface on my Mac. I've been able to build Ipopt successfully, but I'm having trouble with the MEX build. Here is my setup ...

OS X 10.6.8 Snow Leopard
gcc -v :  gcc version 4.2.1 (Apple Inc. build 5666) (dot 3)
gfortran -v  :  gcc version 4.2.1 (Apple Inc. build 5664)
	(from http://r.research.att.com/tools/)
Matlab R2011b (7.13)

Using ...

../configure --with-blas="-framework vecLib" \
    --with-lapack="-framework vecLib" F77=gfortran \
    FFLAGS="-fexceptions -m64 -fbackslash" \
    CFLAGS="-fno-common -no-cpp-precomp -arch x86_64 -m64" \
    CXXFLAGS="-fno-common -no-cpp-precomp -fexceptions -arch x86_64 -m64" \
    -disable-shared CC=gcc-4.0 CXX=g++-4.0

I added the following line to ~/.matlab/R2011b/mexopts.sh (from a Mar 9, 2010 posting by Peter)
    LDFLAGS="$LDFLAGS -framework vecLib"

In Ipopt-3.10.1/build/Ipopt/contrib/MatlabInterface/src/Makefile
    MATLAB_HOME = /Applications/-math/MATLAB_R2011b.app/
    MEXSUFFIX   = mexmaci64

When I run 'make' for the MatlabInterface, I get the following:

$ make
/Applications/-math/MATLAB_R2011b.app//bin/mex -v -cxx -O CC="g++-4.0" CXX="g++-4.0" LD="g++-4.0" COPTIMFLAGS="-fno-common -no-cpp-precomp -fexceptions -arch x86_64 -m64   -DIPOPT_BUILD -DMATLAB_MEXFILE " CXXOPTIMFLAGS="-fno-common -no-cpp-precomp -fexceptions -arch x86_64 -m64   -DIPOPT_BUILD -DMATLAB_MEXFILE " LDOPTIMFLAGS="-fno-common -no-cpp-precomp -fexceptions -arch x86_64 -m64   -DIPOPT_BUILD -DMATLAB_MEXFILE  "  -L/Users/ray/build/Ipopt-3.10.1/build/lib -lipopt  -L/Users/ray/build/Ipopt-3.10.1/build/lib -lcoinmumps -lpthread -framework vecLib -L/usr/lib/gcc/i686-apple-darwin10/4.2.1/x86_64 -L/usr/lib/i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../../i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../.. -lgfortranbegin -lgfortran -lSystem  -L/Users/ray/build/Ipopt-3.10.1/build/lib -lcoinmetis  -framework vecLib -framework vecLib -framework vecLib -lm  -ldl -output ipopt.mexmaci64 matlabexception.o matlabfunctionhandle.o matlabjournal.o iterate.o ipoptoptions.o options.o sparsematrix.o callbackfunctions.o matlabinfo.o matlabprogram.o ipopt.o
-> mexopts.sh sourced from directory (DIR = $PREF_DIR)
   FILE = /Users/ray/.matlab/R2011b/mexopts.sh
->    MATLAB                = /Applications/-math/MATLAB_R2011b.app
->    CC                    = g++-4.0
->    CC flags:
         CFLAGS             = -fno-common -no-cpp-precomp -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5  -fexceptions
         CDEBUGFLAGS        = -g
         COPTIMFLAGS        = -fno-common -no-cpp-precomp -fexceptions -arch x86_64 -m64   -DIPOPT_BUILD -DMATLAB_MEXFILE 
         CLIBS              = -L/Applications/-math/MATLAB_R2011b.app/bin/maci64 -lmx -lmex -lmat -lstdc++
         arguments          =  -DMX_COMPAT_32
->    CXX                   = g++-4.0
->    CXX flags:
         CXXFLAGS           = -fno-common -no-cpp-precomp -fexceptions -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5
         CXXDEBUGFLAGS      = -g
         CXXOPTIMFLAGS      = -fno-common -no-cpp-precomp -fexceptions -arch x86_64 -m64   -DIPOPT_BUILD -DMATLAB_MEXFILE 
         CXXLIBS            = -L/Applications/-math/MATLAB_R2011b.app/bin/maci64 -lmx -lmex -lmat -lstdc++
         arguments          =  -DMX_COMPAT_32
->    FC                    = gfortran
->    FC flags:
         FFLAGS             = -fexceptions -m64 -fbackslash
         FDEBUGFLAGS        = -g
         FOPTIMFLAGS        = -O
         FLIBS              = -L/Applications/-math/MATLAB_R2011b.app/bin/maci64 -lmx -lmex -lmat -L -lgfortran -L/usr/lib/gcc/i686-apple-darwin10/4.2.1/x86_64 -lgfortranbegin
         arguments          =  -DMX_COMPAT_32
->    LD                    = g++-4.0
->    Link flags:
         LDFLAGS            = -Wl,-twolevel_namespace -undefined error -arch x86_64 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5 -bundle -Wl,-exported_symbols_list,/Applications/-math/MATLAB_R2011b.app/extern/lib/maci64/mexFunction.map -framework vecLib
         LDDEBUGFLAGS       = -g
         LDOPTIMFLAGS       = -fno-common -no-cpp-precomp -fexceptions -arch x86_64 -m64   -DIPOPT_BUILD -DMATLAB_MEXFILE  
         LDEXTENSION        = .mexmaci64
         arguments          =  -L/Users/ray/build/Ipopt-3.10.1/build/lib -lipopt -L/Users/ray/build/Ipopt-3.10.1/build/lib -lcoinmumps -lpthread
->    LDCXX                 = 
->    Link flags:
         LDCXXFLAGS         = 
         LDCXXDEBUGFLAGS    = 
         LDCXXOPTIMFLAGS    = 
         LDCXXEXTENSION     = 
         arguments          =  -L/Users/ray/build/Ipopt-3.10.1/build/lib -lipopt -L/Users/ray/build/Ipopt-3.10.1/build/lib -lcoinmumps -lpthread

    mex:  -framework not a valid option.

      MEX [option1 ... optionN] sourcefile1 [... sourcefileN]
          [objectfile1 ... objectfileN] [libraryfile1 ... libraryfileN]

    Use the -help option for more information, or consult the MATLAB External Interfaces Guide.

make: *** [ipopt.mexmaci64] Error 1

So if I manually attempt to run the same call to mex, with all of the '-framework vecLib' entries removed (why are there 4 of them anyway)? Then I get the following error ...

ld: library not found for -lgfortranbegin
collect2: ld returned 1 exit status

    mex: link of ' "ipopt.mexmaci64"' failed.

But I do have ...
I'm guessing all I need is a nudge in the right direction. Any help is appreciated. By the way, once I am successful with this build, I hope to try it on OS X 10.7 Lion as well.


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/20110930/efa5c111/attachment.html>

More information about the Ipopt mailing list