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/libboost_python.so - 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:
- kdevelop (version 4:3.5.3-0ubuntu1)
- libtool (version 2.2.4-0ubuntu4)
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.
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 - libgrump.so 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 makefile.am, this contains all the magic sauce to get auto-tools working.
You can also try the manual approach:
- make -f makefile.cvs
If things break please check that you can run the following in the project directory:
- g++ -Wall -I"/usr/include/python2.5" -c -o grump.o grump.cpp
- g++ -o grump.so -shared --start-group grump.o -lboost_python -lutil -lpthread --end-group
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.