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

发布于 2024-11-09 15:30:08 字数 1202 浏览 0 评论 0原文

我的 Boost.Python 配置/安装中缺少什么?

我正在尝试编译教程示例,但出现 libboost_python not found 错误

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 已运行:

/usr/lib/libboost_python.a -> libboost_python-py27.a
/usr/lib/libboost_python-mt-py26.a -> libboost_python-py26.a
/usr/lib/libboost_python-mt-py26.so -> libboost_python-py26.so.1.42.0
/usr/lib/libboost_python-mt-py27.a -> libboost_python-py27.a
/usr/lib/libboost_python-mt-py27.so -> libboost_python-py27.so.1.42.0
/usr/lib/libboost_python-py26.a
/usr/lib/libboost_python-py26.so -> libboost_python-py26.so.1.42.0
/usr/lib/libboost_python-py26.so.1.42.0
/usr/lib/libboost_python-py27.a
/usr/lib/libboost_python-py27.so -> libboost_python-py27.so.1.42.0
/usr/lib/libboost_python-py27.so.1.42.0
/usr/lib/libboost_python.so -> libboost_python-py27.so

我正在使用默认的 libboost Ubuntu 11.04 的软件包。

我的 user-config.jam

using python : 2.7 ;

What am I missing in my Boost.Python configuration/installation?

I'm trying to compile tutorial example, and I get error with libboost_python not found

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:     '.'

But the library is there, ldconfig.real has been run:

/usr/lib/libboost_python.a -> libboost_python-py27.a
/usr/lib/libboost_python-mt-py26.a -> libboost_python-py26.a
/usr/lib/libboost_python-mt-py26.so -> libboost_python-py26.so.1.42.0
/usr/lib/libboost_python-mt-py27.a -> libboost_python-py27.a
/usr/lib/libboost_python-mt-py27.so -> libboost_python-py27.so.1.42.0
/usr/lib/libboost_python-py26.a
/usr/lib/libboost_python-py26.so -> libboost_python-py26.so.1.42.0
/usr/lib/libboost_python-py26.so.1.42.0
/usr/lib/libboost_python-py27.a
/usr/lib/libboost_python-py27.so -> libboost_python-py27.so.1.42.0
/usr/lib/libboost_python-py27.so.1.42.0
/usr/lib/libboost_python.so -> libboost_python-py27.so

I'm using default libboost packages from Ubuntu 11.04.

My user-config.jam is

using python : 2.7 ;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

做个ˇ局外人 2024-11-16 15:30:08

我在 ubuntu 12.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.) 创建一个 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. ) 即可使用。在Python中:

import hello_ext
print hello_ext.greet()

I had a similar problem on ubuntu 12.04 where I installed all the boost libraries as a package. 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()
一身软味 2024-11-16 15:30:08

仍然不确定这是正确的方法,看起来有点黑客,但以下内容有所帮助:

Jamroot 文件中替换

project
  : requirements <library>libboost_python ;

project
  : requirements <library>/usr/lib/libboost_python.so ;

Still not sure it that's the proper way, seems little hackish, but following helped:

In Jamroot file replaced

project
  : requirements <library>libboost_python ;

with

project
  : requirements <library>/usr/lib/libboost_python.so ;
财迷小姐 2024-11-16 15:30:08

您可以有一个类似以下内容的站点配置文件;

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

(你需要位,不知道为什么)

然后你可以做类似的事情。

project foo 
        : <library>/boost//python

从长远来看,这会让事情变得更容易,因为你不可避免地必须在某个时候更改升压版本。

You could have a site-config file with something like the following ;

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

(you need the < library > bit, not sure why)

then you can do stuff like.

project foo 
        : <library>/boost//python

Makes things easier in the long run, as you inevitably will have to change boost version at some point.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文