Boost.Python sans Jam

Mark Hobbes2176 at yahoo.com
Fri Nov 22 09:35:07 EST 2002


I have this horrible tendency to work on something for awhile, post about 
it, go to bed, wake up, look for an answer to the post, spend another hour 
working on it, and produce the answer to my own question!

In short, I wanted to compile a Boost.Python python extension without doing 
it from within the boost code hierarchy (as the boost examples and tutorial 
do).

I set up ~/include/boost and ~/include/boost/python with all of boost's 
include files [although I don't believe they are all needed ... I only 
think ~/include/boost/python.hpp and ~/include/boost/python/* are 
necessary].

I set up ~/lib/ with libboost_python.so*, libboost_python_debug.so*
libboost_python.so.1.29.0*, and libboost_python_debug.so.1.29.0* .

Now, I realized I needed to do one thing before running [not necessarily 
before compiling my "boostable" extension]:

export LD_LIBRARY_PATH=~/lib

To compile, I used the following command line [there may be some unnecessary 
stuff in here]:

g++ hello.cpp -I/home/mfenner/include -I/usr/include/python2.2/ 
-L/usr/lib/python2.2/config -L/home/mfenner/lib -lpython2.2 -lboost_python 
-o hello.so -shared

Basically, I needed to specify the include files for boost and python, the 
library paths for both the python2.2 and boost_python libraries, and 
specify shared so g++ produces an shared object file.

Now I can just type, in python:

>>>import hello
>>>hello.greet()

Regards,
Mark



More information about the Python-list mailing list