This page contains a simple autotools/kdevelop project that should use boost.python to create a shared library and an executable. The shared library can be imported into python and c++ code called from there!

a simple example

If you would like to use Boost.python in Kdevelop without breaking the nice autotools setup then you've come to right place! (Please note that using autotools for boost is not the reccommended way of doing things - have a look at bjam first.

While the bjam system might be very useful (I did follow all the bjam tutorials) I was unable to find the correct way to link against the already existing /usr/lib/ - I also have a large codebase in Kdevelop, and it irks me to move it over to another toolchain, simply because boost does not play nice with autotools.

These instructions work for me, and I am running Ubuntu 8.10, with the following packages installed:

as well a bunch of other packages provided by build-essential. Your mileage may vary with other OS's.


This project is based on the example given here which creates a .so library called grumpy. Since I had already spent the better part of a day figuring this stuff out I thought the theme was appropriate. I ported it to C++, and added the flags to include the correct python/boost stuff.

Download the source code here!

To compile it you should be able to open the kdevelop project file, and build the project. You will get a dialog, asking you to run automake and friends first, which you should. Hopefully the application will be build successfully. This will create two useful things: an executable (probably in ./debug) and a shared library - suitable for import in python (probably in ./debug/.libs).

If you compare the files in the project with the example given here you'll find that the most interesting differences are in, this contains all the magic sauce to get auto-tools working.

You can also try the manual approach:

If things break please check that you can run the following in the project directory:

these commands work for me, if they don't work for you, it is most likely your setup that needs fixing, rather than the project file/autotools stuff.

Insert large disclaimer here! I do not know auto-tools well at all and I realise that I am going against recommended practice by not using bjam. There is a large chance that this recipe provided above will not work for you. However I would have found a simple tutorial such as this very useful, so I am providing it in the hopes that it will save someone effort. If this person is you then please let me know that I have provided a useful tutorial.

You are here: