Q:

Boost::python example on Ubuntu 12.04

I am trying to build the boost:python example on ubuntu 12.04.
I installed the libraries from package manager (not from source).
I also have not used boost before, and haven't set up any environment variables for this (BOOST_BUILD_PATH is unset).
I get this error :
/usr/share/doc/libboost1.46-doc/examples/libs/python/example/tutorial$ bjam --debug-configuration
notice: found boost-build.jam at /usr/share/doc/libboost1.46-doc/examples/libs/python/example/boost-build.jam
Unable to load Boost.Build: could not find build system.
---------------------------------------------------------
/usr/share/doc/libboost1.46-doc/examples/libs/python/example/boost-build.jam attempted to load the build system by invoking
'boost-build ../../../tools/build/v2 ;'
but we were unable to find "bootstrap.jam" in the specified directory
or in BOOST_BUILD_PATH (searching /usr/share/doc/libboost1.46-doc/examples/libs/python/example/../../../tools/build/v2, /usr/share/boost-build).
Please consult the documentation at 'http://www.boost.org'.

How can I fix it ? 
Where should I point BOOST_BUILD_PATH to ?

A:

I had the same problem and I found the solution here:
http://jayrambhia.wordpress.com/2012/06/25/configuring-boostpython-and-hello-boost/
It turns out that you do not need to use bjam at all. A makefile suffices. I will repeat the the solution from the above link here:
1.) Install the libboost-python package
2.) Create a hello world source file called 'hello_ext.c':
char const* greet()
{
    return "hello, world";
}

#include<boost/python.hpp>
BOOST_PYTHON_MODULE(hello_ext)
{
   using namespace boost::python;
   def("greet",greet);
}

3.) Create a makefile:
PYTHON_VERSION = 2.7
PYTHON_INCLUDE = /usr/include/python$(PYTHON_VERSION)
# location of the Boost Python include files and library
BOOST_INC = /usr/include
BOOST_LIB = /usr/lib
# compile mesh classes
TARGET = hello_ext
$(TARGET).so: $(TARGET).o
    g++ -shared -Wl,--export-dynamic $(TARGET).o -L$(BOOST_LIB) -lboost_python -L/usr   /lib/python$(PYTHON_VERSION)/config -lpython$(PYTHON_VERSION) -o $(TARGET).so
$(TARGET).o: $(TARGET).c
    g++ -I$(PYTHON_INCLUDE) -I$(BOOST_INC) -fPIC -c $(TARGET).c

4.) make
make

5.) Ready to use. In python:
import hello_ext
print hello_ext.greet()

Edited to include a tab.

