-
Notifications
You must be signed in to change notification settings - Fork 86
Guide to Compilation on OSX
As for a unix based operating system, under Mac OS X you will need to compile PaGMO from the source code. The following is described by using Homebrew available at http://brew.sh. We will assume that you have downloaded the git repository and that the working directory is pagmo/
We first suppose that you have a working Python installation. We recommend you to follow the tutorial http://hackercodex.com/guide/python-development-environment-on-mac-osx/ to install Python within a virtual environment to have a full control on your Python installation.
If you are not following the next installation description with Homebrew, then note that you need to compile boost thread and boost serialization. For PyGMO you will need a working python installation and the boost python library. For the GTOP database you will need boost date time.
-
Install your favorite mpi library. For the purpose of this we will use OpenMPI. If you prefer, instead, you can install mpich2. Just type:
brew install openmpi
-
Install the boost libraries system wide (including boost thread and boost serialization) by typing:
brew install boost --with-mpi
-
Install the gsl libraries (optional):
brew install gsl
-
Compile and install nlopt library (optional):
brew install nlopt
-
Create a directory named build within the working directory and move there:
mkdir build cd build
-
Run ccmake to configure PaGMO. If you don't have ccmake already installed, download the binary available at http://www.cmake.org/cmake/resources/software.html). Assuming a system wide installation of the application we type
ccmake ../
-
Select the options you want. Choose to build main.cpp and/or PyGMO (the python module). Be careful to link to the correct python binaries/headers in case you are using the Homebrew Python. Double check that the libraries are well linked to the installed python and not the system python (/usr/lib/libpython2.7.dylib usually point to /System/Library/Frameworks/Python.framework/Versions/2.7/Python). In example, you should have the following includes (with a modified install prefix to the install PyGMO within the selected virtualenv, and the libraries versions corresponding to your system):
CMAKE_INSTALL_PREFIX /Users/<user name>/Virtualenvs/default Boost_INCLUDE_DIR /usr/local/Cellar/boost/1.55.0/include GSL_INCLUDE_DIR /usr/local/Cellar/gsl/1.16/include MPI_CXX_INCLUDE_PATH /usr/local/Cellar/open-mpi/1.7.3/include PYTHON_INCLUDE_DIR /Users/<user name>/Virtualenvs/default/include/python2.7 PYTHON_LIBRARY /Users/<user name>/Virtualenvs/default/lib/python2.7/config/libpython2.7.dylib NLOPT_INCLUDE_DIR /usr/local/Cellar/nlopt/2.4.1/include
Configure two times and generate. Then quit.
-
Now build the code
make
-
Install the libraries and python module by typing
make install
Typical problems are:
- Under windows the code has been compiled several times using minGW and MSVC. Each time is a pain.
- In osx, the python installation is somehow different from linux machines and the correct detection of the site-packages directory can fail and may need to be manually set.
- In osx, the use of homebrew is suggested. Be careful to link to the correct python binaries/headers in case you are using the homebrew python (CMake does not detect them)
- Libraries autodected are messed up ... check carefully your cmake output
- On some systems (e.g Ubuntu) you may experience an large wall of errors reporting an
undefined reference to boost::archive(...)
. This is due to the custom version of gcc that Ubuntu (and possibly other distros) ship with. Quick workaround is swapping the linking order of thepagmo_static
and all the other libraries when building. This is done by modifying the the https://github.com/esa/pagmo/blob/master/CMakeLists.txt file. The lineTARGET_LINK_LIBRARIES(main ${MANDATORY_LIBRARIES} pagmo_static)
needs to be changed toTARGET_LINK_LIBRARIES(main pagmo_static ${MANDATORY_LIBRARIES})
. Other solution is compiling gcc from sources and pointing to it withCMAKE_CXX_COMPILER
andCMAKE_C_COMPILER
in ccmake.