You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This ticket reports problems I have hade with compiling CasADi on my MacBook Pro, in particular to get the Python interface working.
I installed packages using macports:
python26
py26-ipython
gcc45
py26-numpy
py26-scipy
py26-wxpython
py26-matplotlib
py26-lxml
apache-ant
subversion
swig
cmake
py26-cython don't work out of the box, see https://trac.macports.org/ticket/28682
Check the log file for the failed python install, on my system located at:
/opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py26-cython/main.log
and copy the lines below "The correct checksum line may be…" into the port file:
/opt/local/var/macports/sources/rsync.macports.org/release/ports/python/py26-cython/Portfile
to replace the incorrect checksums.
> sudo make install_python
> cd examples
> make
> cd ../bin
> ./rocket_ipopt
The rocket_ipopt test works without problems - Ipopt is invoked and no errors are reported.
Now try a Python example:
ipython
Python 2.6.7 (r267:88850, Jul 28 2011, 18:02:40)
Type "copyright", "credits" or "license" for more information.
IPython 0.10.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.
In [1]: run vdp_collocation.py
Python(50482) malloc: *** error for object 0x7fff70714500: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
zsh: abort ipython
Given that the error seems to be related to strings (basic_string.h) and the string problems I previously encountered in CasADi's XML import, I did some searching on string related problems and came up with the following posts:
The problem may be that the Python-distribution installed by macports is compiled by the XCode compiler (gcc-4.2.1), which is compiled in a way that may cause problems, as described in the posts above. So, when CasADi and Ipopt are compiled using macport's gcc-4.5 or gcc-4.4, there may be an incompatibility between the system libraries of these compilers?
I checked the dependencies of _casadi.so to see if there may be conflicting libraries involved, and it seems that here is:
otool -L ~/svn_projects/CasADi/build/lib/_casadi.so
/Users/jakesson/svn_projects/CasADi/build/lib/_casadi.so:
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/Python (compatibility version 2.6.0, current version 2.6.0)
/usr/lib/libmpi_cxx.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libmpi.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libopen-rte.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libopen-pal.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/Users/jakesson/packages/Ipopt/Ipopt-3.10.0-MA27-install/lib/libipopt.1.dylib (compatibility version 10.0.0, current version 10.0.0)
/Users/jakesson/packages/Ipopt/Ipopt-3.10.0-MA27-install/lib/libcoinhsl.1.dylib (compatibility version 5.0.0, current version 5.0.0)
/Users/jakesson/packages/Ipopt/Ipopt-3.10.0-MA27-install/lib/libcoinlapack.1.dylib (compatibility version 5.0.0, current version 5.0.0)
/Users/jakesson/packages/Ipopt/Ipopt-3.10.0-MA27-install/lib/libcoinblas.1.dylib (compatibility version 4.0.0, current version 4.0.0)
/opt/local/lib/gcc45/libgfortran.3.dylib (compatibility version 4.0.0, current version 4.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.10)
/Users/jakesson/packages/Sundials/sundials-2.4.0-install-non-shared/lib/libsundials_cvodes.2.dylib (compatibility version 3.0.0, current version 3.0.0)
/Users/jakesson/packages/Sundials/sundials-2.4.0-install-non-shared/lib/libsundials_idas.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/Users/jakesson/packages/Sundials/sundials-2.4.0-install-non-shared/lib/libsundials_kinsol.1.dylib (compatibility version 2.0.0, current version 2.0.0)
/Users/jakesson/packages/Sundials/sundials-2.4.0-install-non-shared/lib/libsundials_nvecserial.0.dylib (compatibility version 1.0.0, current version 1.2.0)
/System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate (compatibility version 1.0.0, current version 4.0.0)
/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib (compatibility version 1.0.0, current version 219.0.0)
/opt/local/lib/gcc45/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.14.0)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 830.0.0)
/opt/local/lib/gcc45/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
Notice that libgcc_s.1.dylib is referenced both in the macport version of the compiler (/opt/local/lib) and by the XCode version (/opt/local/lib)
I also tried to compile Python (2.6.7) from sources. In order to make this work, gcc-4.6 is needed, for the reasons described in http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44981, so I installed gcc46 using macports and then compiled Python using
> ../configure --prefix=/Users/jakesson/packages/python2.6/python/python2.6 --enable-shared CXX=g++-mp-4.6 CC=gcc-mp-4.6 > F77=gfortran-mp-4.6
> make
> make install
This installation, too, however, seems to be dependent on the XCode version of libgcc_s.1.dylib:
otool -L ~/packages/python2.6/python/python2.6/lib/libpython2.6.dylib
/Users/jakesson/packages/python2.6/python/python2.6/lib/libpython2.6.dylib:
/Users/jakesson/packages/python2.6/python/python2.6/lib/libpython2.6.dylib (compatibility version 2.6.0, current version 2.6.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 550.42.0)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 830.0.0)
/opt/local/lib/gcc46/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.10)
Yes, this is a really tricky issue. Maybe a good idea is to check with the Ipopt community, maybe someone else has experienced similar problems when using Ipopt from Python on Mac.
We made an attempt to install CasADi on a Mac here and ended up with pretty much the same problems. Did you try any of the following:
\* Using the Python binaries for Mac instead of the Python you get from macports
Nope, I tried only with the macports distros.
\* Compiling CasADi and dependencies using gcc4.2
I tried this, but at least with that version of CasADi I got compilation errors in the generated SWIG code for the Python interface with gcc-4.2. Can you verify that this is still the case?
We made an attempt to install CasADi on a Mac here and ended up with pretty much the same problems. Did you try any of the following:
\* Using the Python binaries for Mac instead of the Python you get from macports
Nope, I tried only with the macports distros.
\* Compiling CasADi and dependencies using gcc4.2
I tried this, but at least with that version of CasADi I got compilation errors in the generated SWIG code for the Python interface with gcc-4.2. Can you verify that this is still the case?
I didn't get that far. I didn't manage to compile the dependencies (Ipopt) using gcc4.2, since gfortran was not available, and it wasn't possible to install it either. I will make an attempt with gcc4.4. Starting from gcc4.5, the names of gcc in macports changed, so maybe that is an indicator that other things changed as well.
With gcc4.4 CasADi's Python interface appears to work if Ipopt is not used. As soon as an Ipopt instance is created, Python crashes. I will try to recompile Ipopt with only static libraries, as I suspect that the DLL loader in Ipopt might be what is causing the problems.
Good news. It works to generate the Python interface if Ipopt has been compiled with disable-shared. Some unrelated problems remain though, as some examples and the test suite fails. Here are the instructions we used:
In [1]: from casadi import *
In [2]: a = ssym("a",2)
Python(30232,0x7fff70daecc0) malloc: *** error for object 0x1057dc7e0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap
Came across the following instructions on how to change the compiler in Macports: http://trac.macports.org/wiki/UsingTheRightCompiler. You really don't want to compile modern numerical software with gcc4.2.
Updated Xcode to latest version (4.3) using App Store and installed "Command Line Tools" from Xcode -> Preferences -> Downloads
Install CMake from website
Compile Ipopt from sources, setting only prefix to /usr/local/
Compile Sundials from sources (with -fPIC)
Installed SWIG from sources (macports version was corrupted). Needed to configure with --without-pcrc
Install easy_install
Make sure Apple's default Python installation works (in our case it was Python 2.7)
Install PySide from website (needed for spyder) which in turn needed the installation of QT4
Install numpy, scipy, ipython, readline, sphinx (needed for spyder) and spyder from easy_install
Download CasADi from SVN
Remove ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES} in the file <CASADI_ROOT>/cmake_modules/FindIPOPT.cmake
Configured and installed CasADi with default options (mkdir build, cd build, cmake .., make, make python, sudo make install_python. After uploading Xcode, clang was chosen as the default C/C++ compiler. If this is not automatic, export CC=/usr/bin/clang, export CXX=/usr/bin/clang++ will probabably work also. Compiling CasADi with Clang is fast but gives quite a few warnings. No errors though, except for an irrelevant one in the documentation subdirectory.
All tests in CasADi's testsuite passed after the installation. The only thing that didn't work was matplotlib. It appears that the matplotlib that you get from easy_install is corrupted and the matplotlib binaries from the website only work with the Python installation from the [www.python.org], and not Apple's default one, which was the only one we got working together with CasADi. Installing matplotlib from sources should work, but we didn't have time to test that.
I will try this recipe on Sebastien's Mac (with Snow Leopard) and then put together installation instructions. Since we tried quite a lot of different variants and installed and uninstalled several software packages, it is likely that I forgot something above.
Ah, also note that the gcc version used to compile Ipopt and SWIG was the default one (4.2). Apple does not appear interested in updating to a newer gcc version and instead concentrate on clang. Therefore it also makes sense to use clang to compile CasADi.
Hi, I am currently a Mac OS X Lion user and I have tried both installing processes described in the previous response and there:https://sourceforge.net/apps/trac/casadi/wiki/InstallationMac.
Unfortunately, none of these methods helps me to get a suitable installation. I have always a problem with Ipopt which is not recognized by the system even if the installation seems to be done successfully.
Could you kindly post a described and suitable installation process so that we could install Casadi simply?
Thank you in advance for your help.
The text was updated successfully, but these errors were encountered:
This ticket reports problems I have hade with compiling CasADi on my MacBook Pro, in particular to get the Python interface working.
Check the log file for the failed python install, on my system located at:
/opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py26-cython/main.log
and copy the lines below "The correct checksum line may be…" into the port file:
/opt/local/var/macports/sources/rsync.macports.org/release/ports/python/py26-cython/Portfile
to replace the incorrect checksums.
http://superuser.com/questions/35256/how-can-i-change-the-default-python-version-on-snow-leopard
No errors reported in testing of Ipopt
Use the following script to run cmake to set up the makefiles:
Then build and install CasADi:
The rocket_ipopt test works without problems - Ipopt is invoked and no errors are reported.
Now try a Python example:
The resulting trace reported is:
Compiling IPOPT with gcc-4.4 gives a slightly more informative error message:
Given that the error seems to be related to strings (basic_string.h) and the string problems I previously encountered in CasADi's XML import, I did some searching on string related problems and came up with the following posts:
http://stackoverflow.com/questions/2234557/c-using-getline-prints-pointer-being-freed-was-not-allocated-in-xcode
http://gcc.gnu.org/ml/gcc-bugs/2009-10/msg00807.html
http://lists.apple.com/archives/cocoa-dev/2009/Sep/msg01199.html
http://lists.macosforge.org/pipermail/macports-dev/2011-June/014877.html
However, this issue should have been fixed in the macports compilers:
https://trac.macports.org/ticket/22234
The problem may be that the Python-distribution installed by macports is compiled by the XCode compiler (gcc-4.2.1), which is compiled in a way that may cause problems, as described in the posts above. So, when CasADi and Ipopt are compiled using macport's gcc-4.5 or gcc-4.4, there may be an incompatibility between the system libraries of these compilers?
I checked the dependencies of _casadi.so to see if there may be conflicting libraries involved, and it seems that here is:
Notice that libgcc_s.1.dylib is referenced both in the macport version of the compiler (/opt/local/lib) and by the XCode version (/opt/local/lib)
This installation, too, however, seems to be dependent on the XCode version of libgcc_s.1.dylib:
In order to compile Numpy, the following patch needs to be applied:
https://trac.macports.org/browser/trunk/dports/python/py26-numpy/files/patch-system_info.py.diff?rev=62626.
After this change it works fine to install numpy in the newly compiled Python installation, and to then compile CasADi and install it in the same installation.
Unfortunately, the very same problem occurs with this Python distro as with the one installed by macports.
Created by None at: 2011-08-04T10:21:35
Last updated at: 2012-10-16T15:55:38
The text was updated successfully, but these errors were encountered: