简体   繁体   English

如何在Ubuntu 9.10上构建Boost.Python示例?

[英]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. 我正在使用Ubuntu 9.10 beta,其存储库包含boost 1.38。 I would like to build the hello-world example. 我想构建一个hello-world示例。 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. 我按照这里的说明( http://www.boost.org/doc/libs/1_40_0/libs/python/doc/tutorial/doc/html/python/hello.html ),找到了示例项目,并发布了“ bjam“命令。 I have installed bjam and boost-build. 我已经安装了bjam和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. 我不太了解Boost(这是我自己的探索练习),以了解为什么包含的Jamroot中的python-extension宏无效。 I am running this example from the install directory, so I have not altered the Jamroot's use-project setting. 我从安装目录运行这个例子,所以我没有改变Jamroot的use-project设置。

As a side question, if I were to just willy-nilly start a project in an arbitrary directory, how would I write my jamroot? 作为一个附带问题,如果我只是不知不觉地在任意目录中启动项目,我将如何编写我的jamroot?

The problem comes from using Ubuntu package instead of boost compiled from source. 问题来自于使用Ubuntu软件包而不是从源代码编译的boost。 You have to edit you Jamroot to say it to use global libboost-python, instead of looking for lib in relative boost source tree. 你必须编辑Jamroot来说它使用全局libboost-python,而不是在相对的boost源树中查找lib。

Summarily you should have these lines at the beginning of your Jamroot: 总而言之,你应该在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. 它被报道为Debian上的一个错误,并且至少在使用libboost-python1.40的lenny上进行了修正......大多数情况下。 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. libboost_python中的示例仍然引用boost_python-mt而不是boost_python,但是/usr/lib/libboost_python.so存在但不存在/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. 希望Ubuntu很快会有相同的修复,下一个用户不会发现这个...我知道你的问题的答案,因为我不久前确实遇到了完全相同的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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