简体   繁体   中英

How can I build the Boost.Python example on Ubuntu 9.10?

I am using Ubuntu 9.10 beta, whose repositories contain boost 1.38. I would like to build the hello-world example. I followed the instructions here ( http://www.boost.org/doc/libs/1_40_0/libs/python/doc/tutorial/doc/html/python/hello.html ), found the example project, and issued the "bjam" command. I have installed bjam and boost-build.

I get the following output:

Jamroot:18: in modules.load
rule python-extension unknown in module Jamfile</usr/share/doc/libboost1.38-doc/examples/libs/python/example>.
/usr/share/boost-build/build/project.jam:312: in load-jamfile
/usr/share/boost-build/build/project.jam:68: in load
/usr/share/boost-build/build/project.jam:170: in project.find
/usr/share/boost-build/build-system.jam:248: in load
/usr/share/boost-build/kernel/modules.jam:261: in import
/usr/share/boost-build/kernel/bootstrap.jam:132: in boost-build
/usr/share/doc/libboost1.38-doc/examples/libs/python/example/boost-build.jam:7: in module scope

I do not know enough about Boost (this is an exploratory exercise for myself) to understand why the python-extension macro in the included Jamroot is not valid. I am running this example from the install directory, so I have not altered the Jamroot's use-project setting.

As a side question, if I were to just willy-nilly start a project in an arbitrary directory, how would I write my jamroot?

The problem comes from using Ubuntu package instead of boost compiled from source. You have to edit you Jamroot to say it to use global libboost-python, instead of looking for lib in relative boost source tree.

Summarily you should have these lines at the beginning of your Jamroot:

using python ;
lib libboost_python : : <name>boost_python ;
project : requirements <library>libboost_python ;

It was reported as a bug on Debian and corrected at least on lenny with libboost-python1.40 ...mostly. The example in libboost_python still refers to boost_python-mt instead of boost_python, but /usr/lib/libboost_python.so exists but not /usr/lib/libboost_python-mt.so.

Hopefully Ubuntu will soon have the same fix and the next user won't stumble on this... I know the answer to your question because I did had the exact same problem not long ago.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM