[Ipopt] interfacing Ipopt with matlab

Rodrigo Lopez-Negrete r.lopez.negrete at gmail.com
Fri Jun 4 14:23:53 EDT 2010


Hi Huizhen,

Quick questions:

In step 9 of your email, did you change  MATLAB_HOME to your matlab
installation dir? If you type

$ ls /c/PROGRA~2/MATLAB/R2008B~1/

On your msys command line, do you see the contents of the matlab
installation folder?

Also, in step 11 point 2, when you set GM_ADD_LIBS. Did you install msys in
c:\msys\1.0 or did you change the installation dir to c:\
msys\uno??

Finally, the error error: unrecognized switch: -CXX. You need to remove the
-cxx flag from the Makefile
in $MyIpoptDir/build/Ipopt/contrib/Matlabinterface/src. I've updated the
compilation instructions in the Ipopt website for this one (
https://projects.coin-or.org/Ipopt/wiki/CompilationHints)

The other errors I don't know why they are showing up... are you sure you've
got matlab properly configured, and that mex file creation is possible using
your matlab installation?

I hope this helps,
 Rodrigo


On Fri, Jun 4, 2010 at 5:41 AM, Huizhen Zhang <zhzzywz at gmail.com> wrote:

> Hello Ipopt-experts  and Rodrigo,
>
> I tried to install the Ipopt on my Laptop with windows XP system, and use the Matlab interface for IPOPt.
>
>
> According to the suggestions from Rodrigo, I did the following:
>
> - windows XP
> - VC 6.0
> - matlab R2008b student
> - MinGW version 5.1.6
> - Msys 1.0.11
> - Ipopt version 3.8.0
>
>
> Details:
>
>
>    - Download  MinGW/TDM <http://www.tdragon.net/recentgcc/> compilers,
>    version 4.3.2-tdm-2 (I've tried other versions, and they don't work)
>       1. gcc-4.3.2-tdm-2-core.tar.gz
>       2. gcc-4.3.2-tdm-2-g++.tar.gz
>       3. gcc-4.3.2-tdm-2-fortran.tar.gz
>    - Extract the compiler files with
>       1. $ tar xzf gcc-4.3.2-tdm-2-core.tar.gz -C /mingw
>       2. $ tar xzf gcc-4.3.2-tdm-2-g++.tar.gz -C /mingw
>       3. $ tar xzf gcc-4.3.2-tdm-2-fortran.tar.gz -C /mingw
>    - Backup libstdc++* just in case
>       1. $ cp /mingw/lib/libstdc++.a /mingw/lib/libstdc++.a.orig
>       2. $ cp /mingw/lib/libstdc++.la /mingw/lib/libstdc++.la.orig
>    - Copy libstdc++.* to /mingw/lib
>       1. $ cp /mingw/lib/gcc/mingw/4.3.2/libstdc++* /mingw/lib/
>
>
>  1.) get the ipopt code
>  2.) get the required ThirdParty code (ASL, Lapack, and BLAS) via the  get comands
>  3.) get the HSL as described (ma27ad.f and mc19ad.f)
>  4.) mkdir   $MyIpoptDir/build
>
>
>
>      cd   $MyIpoptDir/build
>  5.)$MyIpoptDir/configure   --enable-doscompile --disable-shared –-enable-static
>                              ADD_CXXFLAGS="-fexceptions"   ADD_CFLAGS="-fexceptions"
>
>
>
>                              ADD_FFLAGS="-fexceptions"  CC=gcc CXX=g++
>  6.) make
>  7.) make test
>  8.) make install
>
>
> ===> Up to this point everything seems to work fine. The problem appears in the next step to generate the matlab interface.
>
>
>
> 9.) copy the mexopts.bat file generated by gnumex in  $MyIpoptDir/build/Ipopt/contrib/Matlabinterface/src
> 10.) edit the makefile:
>
>
>    1.     MATLAB_HOME = /c/PROGRA~2/MATLAB/R2008B~1/
>    2.     MEXSUFFIX = mexw32
>    3.     MEX =$(MATLAB_HOME)/bin/mex.pl
>
> 11.) edit the mexopt.bat
>
>
>    1. set GM_MEXLANG=cxx
>    2. set GM_ADD_LIBS=-llibmx -llibmex -llibmat
>    -Ld:\msys\uno\home\Administrator\CoinOR\Ipopt_matlab\build\lib -lipopt
>    -lpthread -lm -Ld:/mingw/bin/../lib/gcc/mingw32/4.3.2
>    -Ld:/mingw/bin/../lib/gcc
>    -Ld:/mingw/bin/../lib/gcc/mingw32/4.3.2/../../../../mingw32/lib
>    -Ld:/mingw/bin/../lib/gcc/mingw32/4.3.2/../../.. -L/mingw/lib
>    -lgfortranbegin -lgfortran -lmingw32 -lmoldname -lmingwex -lmsvcrt -luser32
>    -lkernel32 -ladvapi32 -lshell32 -llibmx -llibmex -llibmat
>    3.  set COMPILER=g++
>
> 12. ) Then I type make to generate the interface, some errors appear:
>
>         /c/progra~2/matlab/r2008b~1//bin/mex.pl:  line 95: require:
> command not found
>         /c/progra~2/matlab/r2008b~1//bin/mex.pl:  line 97: sub: command
> not found
>        /c/progra~2/matlab/r2008b~1//bin/mex.pl:  line107: syntax error
> near unexpected token 'else'
>        /c/progra~2/matlab/r2008b~1//bin/mex.pl:  line107: ' else'
>        make: *** [ipopt.mexw32] error 2
>
>   I read the mex.pl file, the commands" require, sub" are in it, but I don't know what to do.
>
>    I also tried to edit the MEX in the makefile as:
>
>
>
>             MEX =$(MATLAB_HOME)/sys/perl/win32/bin/perl.exe $(MATLAB_HOME)/bin/mex.pl
>     then the errors are:
>             /c/progra~2/matlab/r2008b~1//bin/mex.pl: error: unrecognized switch: -CXX.
>
>
>
>             make: *** [ipopt.mexw32] error 2
>
> What should I do, then I can generate the matlab interface successfully.
> I am looking forward your help.
>
> Thanks!
>
> 2010/5/26 Rodrigo Lopez-Negrete <r.lopez.negrete at gmail.com>
>
> Dear Peter,
>>
>> I've had success in doing this in windows xp and with MinGW. I've
>> written down the steps I took in order to do this. You can find them
>> here.
>>
>> https://projects.coin-or.org/Ipopt/wiki/CompilationHints#WinIpopt
>>
>> I hope this helps,
>>   Rodrigo
>>
>> On Wednesday, May 26, 2010, Peter Carbonetto <pcarbo at uchicago.edu> wrote:
>> > There has been some (not very detailed) discussion on installing the
>> Matlab interface on Windows in previous postings to the mailing
>> list---please search the archives of the IPOPT mailing list. Apparently it
>> is tricky to compile the MEX file on Windows. If you have any success,
>> please let us know!
>> >
>> > Peter Carbonetto, Ph.D.
>> > Postdoctoral Reseearcher
>> > Dept. of Human Genetics
>> > University of Chicago
>> >
>> >
>> > Dear all,
>> >
>> > I am new to IPOPT. I want to install Ipopt on Windows XP and use the
>> matlabi nterface. I have downloaded the IPOPT and its thirdPraty(ASL, Blas,
>> HSL, Lapack, Metis
>> >  and Mumps),
>> >  and I have compiled the Ipopt by using the Microsoft Visual Studio
>> files
>> >
>> > (I followed the steps in the file readme.txt which is located in the
>> "BASIc directory\Ipopt\MSVisualStudio\v8").
>> > Now I want to install the matlabinterface in my laptop, how can I
>> install it
>> >  correctly ?
>> > (I read the readme.txt file in the "BASIc
>> directory\Ipopt\contrib\MatlabInte
>> > rface", it seems this file only explains how to install this
>> matlabinterface in UNIX
>> > -based operating system, however,
>> >
>> >  there are not detailed explanation for installing it in the windowsXP).
>> By the way, do I need to install other additional package? If I need, which
>> packages?
>> > Can anyone tell me how I can solve this problem ? Thanks a lot for any
>> help!
>> >
>> >
>> > --
>> > Huizhen Zhang
>> > Statistics and Operations Research
>> > Rey Juan Carlos University (URJC),
>> > C/ Tulip?n s/n, 28933
>> > M?stoles (Madrid),Spain
>> > Tel: +34 91 488 83 22, +34 667300180
>> > Fax: +34 91 488 70 49
>> >
>> >
>> >
>> >
>>
>
>
>
> --
> Huizhen Zhang
> Statistics and Operations Research
> Rey Juan Carlos University (URJC),
> C/ Tulipán s/n, 28933
> Móstoles (Madrid),Spain
>
> Tel: +34 91 488 83 22, +34 667300180
> Fax: +34 91 488 70 49
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://list.coin-or.org/pipermail/ipopt/attachments/20100604/be8ddbde/attachment.html 


More information about the Ipopt mailing list