[Ipopt] Error message when using the matlab interface

Peter Carbonetto pcarbo at uchicago.edu
Tue Mar 1 10:02:05 EST 2011


Paul,

    I followed exactly what you did, and it created a Makefile for me, as 
expected. So no problems there.

    Maybe it would help if you called configure directly from IPOPTDIR (
type "configure" instead of "../configure"). Try that.

Peter

On Mon, 28 Feb 2011, Paul van Hoven wrote:

> Hi Peter!
>
> I tried to build the matlab interface after I compiled Ipopt and installed 
> it.
>
> I think you mean $COINIPOPT/Ipopt/contrib/MatlabInterface or 
> Ipopt/contrib/MatlabInterface-Old instead of Ipopt/contrib/Matlab/src (this 
> one does not exist on my machine, even after compilation of ipopt). Within 
> the first directory I got the "src" folder that contains a Makefile.in. If I 
> execute configure in $COINIPOPT/build this way
>
> ../configure --prefix=/homes/numerik/hoven/Mex/Ipopt \
> CXX=/usr/site-local/bin/g++-4.2 \
> CC=/usr/site-local/bin/gcc-4.2 \
> F77=/usr/site-local/bin/gfortran-4.2 \
> ADD_CXXFLAGS="-fPIC -fexceptions" \
> ADD_CFLAGS="-fPIC -fexceptions" \
> ADD_FFLAGS="-fPIC -fexceptions" \
> --with-matlab-home=/net/matlab/Matlab2009b
>
> make
> make install
>
> The variable MATLAB_HOME in 
> $COINIPOPT/Ipopt/contrib/MatlabInterface/src/Makefile.in is correctly set but 
> the other variables remain undefined and the Makefile remains a Makefile.in 
> and I cannot execute it.
>
> After configure/make the Makefile looks like this:
>
> $COINIPOPT/Ipopt/contrib/MatlabInterface/src> cat Makefile.in
> comments omitted...
> MATLAB_HOME = /net/matlab/Matlab2009b
>
> # Set the suffix for matlab mex files. The contents of the
> # $(MATLAB_HOME)/extern/examples/mex directory might be able to help
> # you in your choice.
> MEXSUFFIX   = mexa64
>
> # This is the command used to call the mex program. Usually, it is
> # just "mex". But it also may be something like
> # /user/local/R2006b/bin/mex if "mex" doesn't work.
> MEX = $(MATLAB_HOME)/bin/mex
>
> #############################################################################
> # Do not modify anything below unless you know what you're doing.
> exec_prefix = @exec_prefix@
> prefix      = @prefix@
> libdir      = @libdir@/coin
>
> CXX         = @CXX@
> CXXFLAGS    = @CXXFLAGS@ -DMATLAB_MEXFILE # -DMWINDEXISINT
> LDFLAGS     = $(CXXFLAGS) @RPATH_FLAGS@
>
> COIN_HAS_PKGCONFIG = @COIN_HAS_PKGCONFIG_TRUE at TRUE
> COIN_CXX_IS_CL = @COIN_CXX_IS_CL_TRUE at TRUE
>
> # Include directories (we use the CYGPATH_W variables to allow compilation 
> with Windows compilers)
> ifeq ($(COIN_HAS_PKGCONFIG), TRUE)
> INCL = `PKG_CONFIG_PATH=@COIN_PKG_CONFIG_PATH@ @PKG_CONFIG@ --cflags ipopt`
> else
> INCL = -I`$(CYGPATH_W) @abs_include_dir@/coin` @IPOPTLIB_CFLAGS_INSTALLED@
> endif
>
> # Linker flags
> ifeq ($(COIN_HAS_PKGCONFIG), TRUE)
> LIBS = `PKG_CONFIG_PATH=@COIN_PKG_CONFIG_PATH@ @PKG_CONFIG@ --libs ipopt`
> else
> ifeq ($(COIN_CXX_IS_CL), TRUE)
>   LIBS = /link /libpath:`$(CYGPATH_W) @abs_lib_dir@` libipopt.lib 
> @IPOPTLIB_LIBS_INSTALLED@
> else
>   LIBS = -L at abs_lib_dir@ -lipopt @IPOPTLIB_LIBS_INSTALLED@
> endif
> endif
>
> # The following is necessary under cygwin, if native compilers are used
> CYGPATH_W = @CYGPATH_W@
>
> MEXFLAGS    = -v -cxx -O CC="$(CXX)" CXX="$(CXX)" LD="$(CXX)"       \
>             COPTIMFLAGS="$(CXXFLAGS)" CXXOPTIMFLAGS="$(CXXFLAGS)" \
>             LDOPTIMFLAGS="$(LDFLAGS)"
>
> TARGET = ipopt.$(MEXSUFFIX)
> OBJS   = matlabexception. at OBJEXT@      \
>        matlabfunctionhandle. at OBJEXT@ \
>        matlabjournal. at OBJEXT@        \
>        iterate. at OBJEXT@              \
>        ipoptoptions. at OBJEXT@         \
>        options. at OBJEXT@              \
>        sparsematrix. at OBJEXT@         \
>        callbackfunctions. at OBJEXT@    \
>        matlabinfo. at OBJEXT@           \
>        matlabprogram. at OBJEXT@        \
>        ipopt. at OBJEXT@
>
> SRCDIR = @srcdir@
> VPATH = $(SRCDIR)
>
> all: $(TARGET)
>
> install: $(TARGET)
>   if test -d $(libdir); then : ; else mkdir $(libdir); fi
>   cp $(SRCDIR)/../ipopt.m $(TARGET) $(libdir)
>
> uninstall:
>   rm -f $(libdir)/ipopt.m $(libdir)/ipopt.$(MEXSUFFIX)
>
> $(TARGET): $(OBJS)
>   $(MEX) $(MEXFLAGS) $(LIBS) -output $@ $^
>
> %. at OBJEXT@: %.cpp
>   $(CXX) $(CXXFLAGS) $(INCL) -I$(MATLAB_HOME)/extern/include \
>       -o $@ -c $^
>
> clean:
>   rm -f $(OBJS) $(TARGET)
>
> distclean: clean
>
>
>
>
> and the command make returns:
>> make
> make: *** No targets specified and no makefile found.  Stop.
>
>
> Paul
>
>
> Peter Carbonetto schrieb:
>> Paul,
>>
>>    Normally when you build the IPOPT libraries, it will automatically 
>> create a Makefile in that Ipopt/contrib/Matlab/src directory, wherever you 
>> specified the target dirctory. Did you look in there after building the 
>> library?
>> 
>> Peter Carbonetto, Ph.D.
>> Postdoctoral Fellow
>> Dept. of Human Genetics
>> University of Chicago
>> 
>>> I downloaded Ipopt and got it compiled on a Linux 64 bit machine. I put
>>> the compiled Ipopt stuff into "~/Mex/Ipopt" which contains the following
>>> subdirectories:
>>> bin  include  lib  share
>>> 
>>> Since I use matlab 7.9 (2009b 64Bit) I wanted to compile the matlab
>>> interface. The interface is located in
>>> $COINOPT/Ipopt/contrib/MatlabInterface/src.
>>> Within that directory should be a Makefile but instead I only found a
>>> Makefile.in file which was completely useless since all variables in
>>> that file weren't set. Therefore I created a Makefile on my own. This is
>>> the Makefile:
>>> 
>>> [MAKEFILE]
>>> MATLAB_HOME = /net/matlab/Matlab2009b
>>> MEXSUFFIX   = mexa64
>>> PATH_TO_IPOPT_COMPILATION=/homes/numerik/
>
>>> /Mex/Ipopt
>>> SRCDIR = /homes/numerik/hoven/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
>>> #Static linking
>>> MEXFLAGS    = -cxx CC='$(CXX)' CXX='$(CXX)' LD='$(CXX)' -lm
>>> -L$(PATH_TO_IPOPT_COMPILATION)/lib/coin -lipopt
>>> -L$(PATH_TO_IPOPT_COMPILATION)/lib/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)/lib/coin -lipopt -largeArrayDims
>>> 
>>> TARGET = ipopt.$(MEXSUFFIX)
>>> OBJS   = matlabjournal.o        \
>>>         matlabexception.o      \
>>>         matlabfunctionhandle.o \
>>>         iterate.o              \
>>>         ipoptoptions.o         \
>>>         options.o              \
>>>         sparsematrix.o         \
>>>         callbackfunctions.o    \
>>>         matlabinfo.o           \
>>>         matlabprogram.o        \
>>>         ipopt.o
>>> 
>>> all: $(TARGET)
>>> 
>>> install: $(TARGET)
>>>        if test -d $(DESTINATION_DIR); then : ; else mkdir
>>> $(DESTINATION_DIR); fi
>>>        cp $(SRCDIR)/../ipopt.m $(TARGET) $(DESTINATION_DIR)
>>>        cp -r $(SRCDIR)/../examples $(DESTINATION_DIR)
>>> 
>>> uninstall:
>>>        rm -f $(DESTINATION_DIR)/ipopt.m
>>> $(DESTINATION_DIR)/ipopt.$(MEXSUFFIX)
>>> 
>>> $(TARGET): $(OBJS)
>>>        $(MEX) $(MEXFLAGS) -output $@ $^
>>> 
>>> %.o: %.cpp
>>>        $(CXX) $(CXXFLAGS) $(INCLUDES) -o $@ -c $^
>>> 
>>> clean:
>>>        rm -f $(OBJS) $(TARGET)
>>> 
>>> distclean: clean
>>> [/MAKEFILE]
>>> 
>>> As you can see I used the setting static linking which I noticed makes
>>> no difference to dynamic linking in terms of the error I encounter when
>>> using matlab. Anyway the compilation process works fine and the matlab
>>> interface is placed in a custom directory called "MatlabInterface"
>>> underneth ~/Mex/Ipopt. The directory contents look like this:
>>> ~/Mex/Ipopt/MatlabInterface> ls
>>> examples  ipopt.m  ipopt.mexa64
>>> 
>>> examples is a directory containing some matlab m-files for testing ipopt
>>> matlab interface.
>>> 
>>> Then I started matlab to run the test matlab program to check that the
>>> interface works. So I did the following
>>> 
>>> matlab -nodisplay(enter)
>>> 
>>> 
>>> < M A T L A B (R) >
>>> 
>>> Copyright 1984-2009 The MathWorks, Inc.
>>> 
>>> Version 7.9.0.529 (R2009b) 64-bit (glnxa64)
>>> 
>>> August 12, 2009
>>> 
>>>
>>>  To get started, type one of these: helpwin, helpdesk, or demo.
>>>  For product information, visit www.mathworks.com.
>>> 
>>> >> cd ~/Mex/Ipopt/MatlabInterface/examples/
>>> >> pwd
>>> 
>>> ans =
>>> 
>>> /homes/numerik/hoven/Mex/Ipopt/MatlabInterface/examples
>>> 
>>> >> addpath /homes/numerik/hoven/Mex/Ipopt/MatlabInterface
>>> >> examplelasso
>>> 
>>> ****************************************************************************** 
>>> This program contains Ipopt, a library for large-scale nonlinear
>>> optimization.
>>> Ipopt is released as open source code under the Eclipse Public License
>>> (EPL).
>>>         For more information visit http://projects.coin-or.org/Ipopt
>>> ****************************************************************************** 
>>> 
>>> This is Ipopt version 3.9.2, running with linear solver ma27.
>>> 
>>> Function "mxGetJc_700" is obsolete in file "compat32.cpp", line 292.
>>> (64-bit mex files using sparse matrices must be rebuilt with the
>>> "-largeArrayDims" option.  See the R2006b release notes for more details.)
>>> Exception of type: IpoptException in file "Unknown File" at line -1:
>>> Exception message: Unknown Exception caught in Ipopt
>>> Solution:
>>>     0
>>>     0
>>>     0
>>>     0
>>>     0
>>>     0
>>>     0
>>>     0
>>> 
>>> >>
>>> 
>>> I find this message quite strange since I added the "-largeArrayDims"
>>> option in the Mex compiler flags. Even so I get this error. Why?
>>> 
>>> _______________________________________________
>>> Ipopt mailing list
>>> Ipopt at list.coin-or.org
>>> http://list.coin-or.org/mailman/listinfo/ipopt
>>> 
>
>



More information about the Ipopt mailing list