提升python库编译错误

时间:2015-10-21 12:07:35

标签: python c++ boost

在将我的共享库hello.so导入python期间尝试克服错误时(如Import Error on boost python hello program中所述)我遵循其中一个答案的建议,即尝试使用以下两行:

g++ -c -fPIC -I boost_1_59_0/ -I /usr/include/python2.7/ hello.cpp -o hello.o
g++ -I boost_1_59_0/ -I /usr/include/python2.7/ -shared -Wl,-soname,hello.so -o hello.so  hello.o -lpython2.7 -lboost_python

第一线有效;然而,第二个产生错误:

/usr/bin/ld: cannot find -lboost_python
collect2: error: ld returned 1 exit status

经过一些谷歌搜索后,我尝试将-lboost_python替换为 - lboost_python-py27-lboost_python2.7。然而,结果是一样的。

如果我省略了最后一个参数,我会收到python中的错误:

>>> import hello
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: ./hello.so: undefined symbol: _ZNK5boost6python7objects21py_function_impl_base9max_arityEv

我在Ubuntu 14.04.3 LTS下工作并使用python 2.7.6

有人可以帮我正确编译库吗?

0 个答案:

没有答案
相关问题