Friday, May 30, 2008

Installing boost::python on Leopard

This is a memo when I installed boost::python on my iMac. For some reason I couldn't make the boost::python regression tests passed but boost itself seems to be installed fine.

1) Edit boost_1_35_0/tools/build/v2/tools/darwin.jam. insert semicolon between
-Wl,-dead_strip and -no_dead_strip_inits_and_terms

2) Made a dummy user-config.jam in my home dir (or root), which is

using darwin
;

3) build boost with
bjam -toolset=darwin python

4) Made a symbolic link
ln -s boost-1_35/boost .

5) Got an example source code from http://www.kmonos.net/alang/boost/classes/python.html

6) Built extension with
gcc my_sample.cpp -L/usr/local/lib -dylib /usr/local/lib/libboost_python-mt-1_35.dylib -I/usr/local/include -framework Python -I/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/ -lstdc++ -dynamiclib -o my_sample.so

I don't know if 1) is necessary. Doing so was just natural thinking that they are both linker options, and without 2) bjam tried to execute gcc with weird options when linking libboost_python-mt-1_35.dylib, and I still don't know if I can use bjam to build an extension.

No comments: