bjam“无法找到名为”libboost_python“的文件或目标”`

2024-09-29 02:28:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我在我的Boost.Python配置/安装?在

我试图编译教程示例,但我得到了一个错误:找不到libboost_python

cd /usr/share/doc/libboost1.42-doc/examples/libs/python/example/tutorial
bjam
error: Unable to find file or target named
error:     'libboost_python'
error: referred from project at
error:     '.'

但是库在那里,ldconfig.real已经运行:

^{pr2}$

我使用的是Ubuntu11.04中的默认libboost包。在

我的user-config.jam

using python : 2.7 ;

Tags: 示例sharedocexampleusr错误cd教程
3条回答

我在ubuntu12.04上也遇到了类似的问题,我把所有的boost库都作为一个包安装了。我在这里找到了解决办法:

http://jayrambhia.wordpress.com/2012/06/25/configuring-boostpython-and-hello-boost/

事实证明,你根本不需要使用bjam。一个makefile就足够了。我将在这里重复上述链接中的解决方案:

1.)安装libboost python包

2.)创建一个名为“hello_ext.c”的hello world源文件:

char const* greet()
{
    return "hello, world";
}

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

3.)创建生成文件:

^{pr2}$

4.)品牌

make

5.)随时可用。在python中:

import hello_ext
print hello_ext.greet()

你可以有一个站点配置文件,包含如下内容:

using boost : 1.48 : <include>/usr/include/boost-1_48 <library>/usr/lib ;

(您需要<;library>;位,不确定原因)

然后你就可以像这样做了。在

^{pr2}$

从长远来看,这会使事情变得更简单,因为在某个时刻,您不可避免地要更改boost版本。在

仍然不确定这是正确的方法,似乎有点老套,但以下内容有所帮助:

Jamroot文件中被替换

project
  : requirements <library>libboost_python ;

^{pr2}$

相关问题 更多 >