gpt4 book ai didi

python - 链接libboost_python时出现错误

转载 作者:太空宇宙 更新时间:2023-11-03 19:25:10 27 4
gpt4 key购买 nike

我想构建这个openNERO为了我自己。据其building tutorial ,我还使用 python 2.7.2 构建了 Boost 1.48。通过Boost,openNERO编译成功。但当它尝试链接时,ld 提示

CMakeFiles/OpenNERO.dir/scripting/scripting.cpp.o: In function `initOpenNero':
~/svn/opennero/trunk/source/scripting/scripting.cpp:21: undefined reference to `boost::python::detail::init_module(char const*, void (*)())'
/usr/local/lib/libboost_python.so: undefined reference to `PyModule_Create2'
/usr/local/lib/libboost_python.so: undefined reference to `PyBytes_AsString'
/usr/local/lib/libboost_python.so: undefined reference to `PyBytes_Size'
/usr/local/lib/libboost_python.so: undefined reference to `_PyUnicode_AsString'
/usr/local/lib/libboost_python.so: undefined reference to `PyUnicode_InternFromString'
collect2: ld returned 1 exit status

有人可以给我关于这个问题的提示吗?谢谢~

更新 1: [已删除]

更新2:感谢this post 。我使用 nm 来检查 init_module 的签名,但它打印:

$nm libboost_python.so.1.48.0 |c++filt|grep init_module
0002e710 T boost::python::detail::init_module(PyModuleDef&, void (*)())

这是 source file 的片段:

#  if PY_VERSION_HEX >= 0x03000000
BOOST_PYTHON_DECL PyObject* init_module(PyModuleDef&, void(*)());
# else
BOOST_PYTHON_DECL PyObject* init_module(char const* name, void(*)());
# endif

所以它是Python 3.x的。但我确实使用参数 --with-python-version=2.7 构建了 Boost。此外,我使用 update-alternatives 来选择 Python 2.7。那么为什么 PY_VERSION_HEX 仍然不正确?

最佳答案

我记得我第一次用python 3.2构建了boost,所以我删除了所有生成的文件并再次重新构建了boost。这次一切都正确了。看来旧文件不会被覆盖。

关于python - 链接libboost_python时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8394207/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com