Skip to content

Building libcmaes on Mac OSX

beniz edited this page Dec 17, 2014 · 21 revisions

Building libcmaes

Instructions for compiling on OSX Maverick (10.9) [untested on other versions] with Mac Ports. Similar instructions should work for Homebrew users as well:

  • install macports and export PATH:
export PATH=$PATH:/opt/local/bin:/opt/local/sbin:/usr/bin:/usr/local/git/bin
  • install gcc-47 or higher (gcc-48, gcc-49) from macports
sudo port install gcc48
sudo port install autoconf
sudo port install automake
  • install eigen3 from macports
sudo port install eigen3
  • install gflags from macports:
sudo port install gflags +gcc48
  • get libcmaes from github:
git clone https://github.com/beniz/libcmaes.git
  • configure libcmaes:
./autogen.sh
./configure CC=/opt/local/bin/gcc CXX=/opt/local/bin/g++ --with-eigen3-include=/opt/local/include/eigen3 CXXFLAGS="-lstdc++ -I/opt/local/include -O4" LDADD=-lgflags LDFLAGS=-L/opt/local/lib
  • build libcmaes
make
  • test libcmaes
./tests/test_functions

should return results of a run on fsphere in 2-D.

Building the library with Python bindings

Python bindings are yet not part of the production code, so switch to the dedicated branch:

git checkout python

The bindings have dependencies on:

  • boost-python
  • numpy Install both as needed:
sudo port install boost +gcc48
sudo port install py-numpy

Configure and build:

./autogen.sh
./configure CC=/opt/local/bin/gcc CXX=/opt/local/bin/g++ --with-eigen3-include=/opt/local/include/eigen3 CXXFLAGS="-lstdc++ -I/opt/local/include -O4 -I/opt/local/include/ -I/opt/local//Library/Frameworks/Python.framework/Versions/2.7/include -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include" LDADD=-lgflags LDFLAGS="-L/opt/local/lib" BOOST_LDFLAGS=-L/opt/local/lib --enable-python PYTHON=/opt/local/bin/python PYTHON_EXTRA_LDFLAGS="-u _PyMac_Error"  LDFLAGS="-L/opt/local/lib `python-config --ldflags` `python-config --libs`"
make

Test your bindings:

cd python
export DYLD_LIBRARY_PATH=../src/.libs
/opt/local/bin/python ptest_bounds.py