[Ipopt] Problem running Ipopt matlab interface

Paul van Hoven paul.van.hoven at googlemail.com
Thu Jul 26 05:34:09 EDT 2012


Thanks for the answers. I built a static version of ipopt. But now I
get an error when compiling the Matlabinterface:

This was my configure call for compiling ipopt:
../configure --prefix=/homes/numerik/paul/lib/Ipopt \
CXX=/usr/site-local/bin/g++-4.2 \
CC=/usr/site-local/bin/gcc-4.2 \
F77=/usr/bin/gfortran-4.6 \
ADD_CXXFLAGS="-fPIC -fexceptions -DFUNNY_LAPACK_FINT" \
ADD_CFLAGS="-fPIC -fexceptions" \
ADD_FFLAGS="-fPIC -fexceptions" \
--with-matlab-home=/net/matlab/Matlab2011b \
LDFLAGS="-L/usr/lib64 -lblas_pic" \
-disable-shared

Ipopt compiled fine, but when I try to compile the matlab interface I
get an error:
paul at gauss:~/lib_src/CoinIpopt/Ipopt/contrib/MatlabInterface/src> make
/usr/site-local/bin/g++-4.2 -fPIC -DMX_COMPAT_32 -DMATLAB_MEX_FILE
-DMWINDEXISINT -I/homes/numerik/paul/lib/Ipopt/include/coin
-I/net/matlab/Matlab2011b/extern/include -o matlabjournal.o -c
matlabjournal.cpp
/usr/site-local/bin/g++-4.2 -fPIC -DMX_COMPAT_32 -DMATLAB_MEX_FILE
-DMWINDEXISINT -I/homes/numerik/paul/lib/Ipopt/include/coin
-I/net/matlab/Matlab2011b/extern/include -o matlabexception.o -c
matlabexception.cpp
/usr/site-local/bin/g++-4.2 -fPIC -DMX_COMPAT_32 -DMATLAB_MEX_FILE
-DMWINDEXISINT -I/homes/numerik/paul/lib/Ipopt/include/coin
-I/net/matlab/Matlab2011b/extern/include -o matlabfunctionhandle.o -c
matlabfunctionhandle.cpp
/usr/site-local/bin/g++-4.2 -fPIC -DMX_COMPAT_32 -DMATLAB_MEX_FILE
-DMWINDEXISINT -I/homes/numerik/paul/lib/Ipopt/include/coin
-I/net/matlab/Matlab2011b/extern/include -o iterate.o -c iterate.cpp
/usr/site-local/bin/g++-4.2 -fPIC -DMX_COMPAT_32 -DMATLAB_MEX_FILE
-DMWINDEXISINT -I/homes/numerik/paul/lib/Ipopt/include/coin
-I/net/matlab/Matlab2011b/extern/include -o ipoptoptions.o -c
ipoptoptions.cpp
/usr/site-local/bin/g++-4.2 -fPIC -DMX_COMPAT_32 -DMATLAB_MEX_FILE
-DMWINDEXISINT -I/homes/numerik/paul/lib/Ipopt/include/coin
-I/net/matlab/Matlab2011b/extern/include -o options.o -c options.cpp
/usr/site-local/bin/g++-4.2 -fPIC -DMX_COMPAT_32 -DMATLAB_MEX_FILE
-DMWINDEXISINT -I/homes/numerik/paul/lib/Ipopt/include/coin
-I/net/matlab/Matlab2011b/extern/include -o sparsematrix.o -c
sparsematrix.cpp
/usr/site-local/bin/g++-4.2 -fPIC -DMX_COMPAT_32 -DMATLAB_MEX_FILE
-DMWINDEXISINT -I/homes/numerik/paul/lib/Ipopt/include/coin
-I/net/matlab/Matlab2011b/extern/include -o callbackfunctions.o -c
callbackfunctions.cpp
/usr/site-local/bin/g++-4.2 -fPIC -DMX_COMPAT_32 -DMATLAB_MEX_FILE
-DMWINDEXISINT -I/homes/numerik/paul/lib/Ipopt/include/coin
-I/net/matlab/Matlab2011b/extern/include -o matlabinfo.o -c
matlabinfo.cpp
/usr/site-local/bin/g++-4.2 -fPIC -DMX_COMPAT_32 -DMATLAB_MEX_FILE
-DMWINDEXISINT -I/homes/numerik/paul/lib/Ipopt/include/coin
-I/net/matlab/Matlab2011b/extern/include -o matlabprogram.o -c
matlabprogram.cpp
/usr/site-local/bin/g++-4.2 -fPIC -DMX_COMPAT_32 -DMATLAB_MEX_FILE
-DMWINDEXISINT -I/homes/numerik/paul/lib/Ipopt/include/coin
-I/net/matlab/Matlab2011b/extern/include -o ipopt.o -c ipopt.cpp
/net/matlab/Matlab2011b/bin/mex -cxx CC='/usr/site-local/bin/g++-4.2'
CXX='/usr/site-local/bin/g++-4.2' LD='/usr/site-local/bin/g++-4.2' -lm
-L/homes/numerik/paul/lib/Ipopt/lib64/coin -lipopt
-L/homes/numerik/paul/lib/Ipopt/lib64/coin/ThirdParty -lcoinlapack
-lcoinblas -lcoinhsl -lamplsolver
-L/usr/site-local/lib/gcc/x86_64-unknown-linux-gnu/4.2.4 -lgfortran
-ldl -largeArrayDims -output ipopt.mexa64 matlabjournal.o
matlabexception.o matlabfunctionhandle.o iterate.o ipoptoptions.o
options.o sparsematrix.o callbackfunctions.o matlabinfo.o
matlabprogram.o ipopt.o
/homes/numerik/paul/lib/Ipopt/lib64/coin/ThirdParty/libcoinlapack.a(dlamch.o):
In function `dlamc2_':
dlamch.f:(.text+0x762): undefined reference to
`_gfortran_transfer_integer_write'
/homes/numerik/paul/lib/Ipopt/lib64/coin/ThirdParty/libcoinblas.a(xerbla.o):
In function `xerbla_':
xerbla.f:(.text+0x77): undefined reference to
`_gfortran_transfer_character_write'
xerbla.f:(.text+0x87): undefined reference to `_gfortran_transfer_integer_write'
/homes/numerik/paul/lib/Ipopt/lib64/coin/ThirdParty/libcoinhsl.a(ma27ad.o):
In function `ma27od_':
ma27ad.f:(.text+0x2f86): undefined reference to
`_gfortran_transfer_integer_write'
ma27ad.f:(.text+0x2fa0): undefined reference to
`_gfortran_transfer_integer_write'
/homes/numerik/paul/lib/Ipopt/lib64/coin/ThirdParty/libcoinhsl.a(ma27ad.o):
In function `ma27nd_':
ma27ad.f:(.text+0x3834): undefined reference to
`_gfortran_transfer_integer_write'
ma27ad.f:(.text+0x3854): undefined reference to
`_gfortran_transfer_integer_write'
/homes/numerik/paul/lib/Ipopt/lib64/coin/ThirdParty/libcoinhsl.a(ma27ad.o):ma27ad.f:(.text+0x3873):
more undefined references to `_gfortran_transfer_integer_write' follow
/homes/numerik/paul/lib/Ipopt/lib64/coin/ThirdParty/libcoinhsl.a(ma27ad.o):
In function `ma27ad_':
ma27ad.f:(.text+0x722c): undefined reference to `_gfortran_transfer_real_write'
ma27ad.f:(.text+0x723d): undefined reference to
`_gfortran_transfer_integer_write'
ma27ad.f:(.text+0x724e): undefined reference to
`_gfortran_transfer_integer_write'
ma27ad.f:(.text+0x725f): undefined reference to
`_gfortran_transfer_integer_write'
ma27ad.f:(.text+0x7270): undefined reference to
`_gfortran_transfer_integer_write'
ma27ad.f:(.text+0x7281): undefined reference to
`_gfortran_transfer_integer_write'
/homes/numerik/paul/lib/Ipopt/lib64/coin/ThirdParty/libcoinhsl.a(ma27ad.o):ma27ad.f:(.text+0x7292):
more undefined references to `_gfortran_transfer_integer_write' follow
/homes/numerik/paul/lib/Ipopt/lib64/coin/ThirdParty/libcoinhsl.a(ma27ad.o):
In function `ma27bd_':
ma27ad.f:(.text+0x7d05): undefined reference to `_gfortran_transfer_real_write'
ma27ad.f:(.text+0x7dd5): undefined reference to `_gfortran_transfer_real_write'
ma27ad.f:(.text+0x7dea): undefined reference to
`_gfortran_transfer_integer_write'
ma27ad.f:(.text+0x7dff): undefined reference to
`_gfortran_transfer_integer_write'
ma27ad.f:(.text+0x7efe): undefined reference to
`_gfortran_transfer_integer_write'
ma27ad.f:(.text+0x7ff6): undefined reference to
`_gfortran_transfer_integer_write'
ma27ad.f:(.text+0x80d6): undefined reference to
`_gfortran_transfer_integer_write'
/homes/numerik/paul/lib/Ipopt/lib64/coin/ThirdParty/libcoinhsl.a(ma27ad.o):ma27ad.f:(.text+0x81bb):
more undefined references to `_gfortran_transfer_integer_write' follow
/homes/numerik/paul/lib/Ipopt/lib64/coin/ThirdParty/libcoinhsl.a(ma27ad.o):
In function `ma27bd_':
ma27ad.f:(.text+0x8686): undefined reference to `_gfortran_transfer_real_write'
ma27ad.f:(.text+0x8766): undefined reference to
`_gfortran_transfer_integer_write'
ma27ad.f:(.text+0x87e5): undefined reference to
`_gfortran_transfer_integer_write'
ma27ad.f:(.text+0x8a9e): undefined reference to
`_gfortran_transfer_integer_write'
ma27ad.f:(.text+0x8b21): undefined reference to
`_gfortran_transfer_character_write'
ma27ad.f:(.text+0x8bad): undefined reference to
`_gfortran_transfer_integer_write'
ma27ad.f:(.text+0x8c2e): undefined reference to
`_gfortran_transfer_integer_write'
ma27ad.f:(.text+0x8cbf): undefined reference to
`_gfortran_transfer_integer_write'
ma27ad.f:(.text+0x8d43): undefined reference to
`_gfortran_transfer_integer_write'
ma27ad.f:(.text+0x8dba): undefined reference to
`_gfortran_transfer_integer_write'
/homes/numerik/paul/lib/Ipopt/lib64/coin/ThirdParty/libcoinhsl.a(ma27ad.o):ma27ad.f:(.text+0x8e9b):
more undefined references to `_gfortran_transfer_integer_write' follow
/homes/numerik/paul/lib/Ipopt/lib64/coin/ThirdParty/libcoinhsl.a(ma27ad.o):
In function `ma27cd_':
ma27ad.f:(.text+0x931e): undefined reference to `_gfortran_transfer_real_write'
ma27ad.f:(.text+0x940d): undefined reference to `_gfortran_transfer_real_write'
ma27ad.f:(.text+0x9626): undefined reference to `_gfortran_transfer_real_write'
/homes/numerik/paul/lib/Ipopt/lib64/coin/ThirdParty/libcoinhsl.a(mc19ad.o):
In function `mc19ad_':
mc19ad.f:(.text+0x2c0): undefined reference to
`_gfortran_transfer_integer_write'
mc19ad.f:(.text+0x2da): undefined reference to
`_gfortran_transfer_integer_write'
mc19ad.f:(.text+0x2f4): undefined reference to
`_gfortran_transfer_integer_write'
mc19ad.f:(.text+0xf87): undefined reference to
`_gfortran_transfer_integer_write'
collect2: ld returned 1 exit status

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

make: *** [ipopt.mexa64] Fehler 1




2012/7/7 Tony Kelman <kelman at berkeley.edu>:
> Paul,
>
> It looks like the Mathworks recommended compiler for R2011b is GCC/gfortran
> 4.3, see http://www.mathworks.com/support/compilers/R2011b/glnxa64.html.
> Successful compilation of the mex file and a working Matlab interface are a
> bit different, unfortunately.
>
> I've noticed this issue with Matlab, it loads its own set of .so libraries
> which are not always compatible with what you compiled Ipopt against.
> Particularly since you used F77=/usr/bin/gfortran-4.6 to compile Ipopt (and
> the ThirdParty sources like Lapack). Before you go to the trouble of
> switching to GCC/gfortran 4.3 though, will you be needing a shared Ipopt
> library file, or do you just want to use the Matlab interface? If the
> latter, I recommend you compile Ipopt with static libraries by adding
> --disable-shared to the configure command.
>
> Since you are using the coinlapack and coinblas reference implementations,
> static libraries should also work around the namespace collisions
> (http://list.coin-or.org/pipermail/ipopt/2011-March/002376.html) and
> incompatible 32/64 bit integer API problem that will affect every linear
> solver that uses BLAS (all but MA27). If you need to use a shared-library
> BLAS, it is possible to force Matlab to use your BLAS library instead of its
> own by using the BLAS_VERSION environment variable, as formerly documented
> here:
> http://web.archive.org/web/20090615072921/http://www.mathworks.com/support/solutions/en/data/1-18QUC/
>
> Matlab also has its own MA57 library with an incompatible API to the version
> Ipopt uses, but the problem can be avoided by compiling libcoinhsl as a
> static library. If you require libcoinhsl to be a shared library you can
> force Matlab to load libcoinhsl.so before loading its own libmwma57.so by
> using the LD_PRELOAD environment variable, but then the Matlab command ldl
> will not function properly on sparse matrices.
>
> -Tony
>
> -----Original Message----- Date: Fri, 6 Jul 2012 13:19:13 +0200
> From: Paul van Hoven <paul.van.hoven at googlemail.com>
> To: ipopt mailing list <ipopt at list.coin-or.org>
> Subject: [Ipopt] Problem running Ipopt matlab interface
> Message-ID:
> <CANqzD4P00-EO9_aQ=8v9-QjGJDzU2cW+VooNc9ikoKTvEa8vLg at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
>
> Hi, I just successfully compiled and installed ipopt on a linux
> machine. Now I'd like to use the matlab interface. Actually everything
> works fine, the interface compiles fine without any errors or
> warnings, the compiler version GCC 4.2 works also fine with matlab so
> there is no warning as well, and the interface is correctly installed.
> But when I try to run a simple matlab demo app I get the following
> error:
>
>>> IpoptDemo.clusterRunme
>
> ------------------------------------------
> Invalid MEX-file
> '/homes/numerik/paul/lib/Ipopt/MatlabInterface/ipopt.mexa64':
> /net/matlab/Matlab2011b/bin/glnxa64/../../sys/os/glnxa64/libgfortran.so.3:
> version `GFORTRAN_1.4' not
> found (required by
> /homes/numerik/paul/lib/Ipopt/lib64/coin/ThirdParty/libcoinlapack.so.1)
>
> Error in IpoptDemo.runme (line 45)
>            [x info] = ipopt(x0,funcs,options);
>
> Error in IpoptDemo.clusterRunme (line 9)
>            IpoptDemo.runme;
>
>
> I'm not shure if it helps but these are the first lines of the
> makefile for the matlab interface:
>
> MATLAB_HOME =/net/matlab/Matlab2011b
> MEXSUFFIX   =mexa64
> PATH_TO_IPOPT_COMPILATION= /homes/numerik/paul/lib/Ipopt
> SRCDIR =
> /homes/numerik/paul/lib_src/CoinIpopt/Ipopt/contrib/MatlabInterface/src
>
> ###############################################################################################
> DESTINATION_DIR = $(PATH_TO_IPOPT_COMPILATION)/MatlabInterface
> MEX = $(MATLAB_HOME)/bin/mex
> #Pay attention to add a by your matlab version supported g++
> CXX         = /usr/site-local/bin/g++-4.2
> CXXFLAGS    = -fPIC -DMX_COMPAT_32 -DMATLAB_MEX_FILE -DMWINDEXISINT
>
> INCLUDES        = -I$(PATH_TO_IPOPT_COMPILATION)/include/coin
> -I$(MATLAB_HOME)/extern/include
>
> MEXFLAGS    = -cxx CC='$(CXX)' CXX='$(CXX)' LD='$(CXX)' -lm
> -L$(PATH_TO_IPOPT_COMPILATION)/lib64/coin -lipopt \
>
> -L$(PATH_TO_IPOPT_COMPILATION)/lib64/coin/ThirdParty -lcoinlapack
> -lcoinblas -lcoinhsl -lamplsolver \
>
> -L/usr/site-local/lib/gcc/x86_64-unknown-linux-gnu/4.2.4 -lgfortran
> -ldl -largeArrayDims
> #Dynamic linking
> #MEXFLAGS    = -cxx CC='$(CXX)' CXX='$(CXX)' LD='$(CXX)' -lm
> -L$(PATH_TO_IPOPT_COMPILATION)/lib64/coin -lipopt -largeArrayDims
>
>
> And this was the configure call for configuring ipopt:
> ../configure --prefix=/homes/numerik/paul/lib/Ipopt \
> CXX=/usr/site-local/bin/g++-4.2 \
> CC=/usr/site-local/bin/gcc-4.2 \
> F77=/usr/bin/gfortran-4.6 \
> ADD_CXXFLAGS="-fPIC -fexceptions -DFUNNY_LAPACK_FINT" \
> ADD_CFLAGS="-fPIC -fexceptions" \
> ADD_FFLAGS="-fPIC -fexceptions" \
> --with-matlab-home=/net/matlab/Matlab2011b
>
> This is what I did so far:
> 1. I checked that a file called "libgfortran.so.3" is in the directory
> "/net/matlab/Matlab2011b/bin/glnxa64/../../sys/os/glnxa64"
> 2. I added the path to the LD_LIBRARY_PATH which had no effect
> 3. I added an environment path in matlab itself by
> addpath('/net/matlab/Matlab2011b/bin/glnxa64/../../sys/os/glnxa64')
> which also had no effect.
> 4. A simple ipopt demo app written in c++ works fine. So I checked
> that the installed ipopt version works.
>
> Any suggestions how I could repair this problem?
>
>
> ------------------------------
>
>
> _______________________________________________
> Ipopt mailing list
> Ipopt at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/ipopt
>
>
> End of Ipopt Digest, Vol 91, Issue 4
> ************************************


More information about the Ipopt mailing list