我正在尝试针对我的自定义 python 版本编译 boost 并出现“ undefined reference ”错误。这里去细节:
1) 我按照 autodesk maya 的要求构建了支持 unicode=ucs4 的 python
./configure --prefix=/v/pkgs/python/dep/2.7.14 --enable-unicode=ucs4
make
make install
2) 使用此命令构建 boost
b2 -j 4 --layout=versioned --build-type=complete --debug-configuration stage
和配置文件 ./tools/build/src/user-config.jam 以使用我的 python 构建。
using python
: 2.7
: /v/pkgs/python/dep/2.7.14
;
这是 b2 输出的一部分,用于确认 python 选择成功:
notice: [python-cfg] Configuring python...
notice: [python-cfg] user-specified version: "2.7"
notice: [python-cfg] user-specified cmd-or-prefix: "/v/pkgs/python/dep/2.7.14"
notice: [python-cfg] Checking interpreter command "/v/pkgs/python/dep/2.7.14/bin/python2.7"...
notice: [python-cfg] running command '/v/pkgs/python/dep/2.7.14/bin/python2.7 -c "from sys import *; print('version=%d.%d\nplatform=%s\nprefix=%s\nexec_prefix=%s\nexecutable=%s' % (version_info[0],version_info[1],platform,prefix,exec_prefix,executable))" 2>&1'
notice: [python-cfg] ...requested configuration matched!
notice: [python-cfg] Details of this Python configuration:
notice: [python-cfg] interpreter command: "/v/pkgs/python/dep/2.7.14/bin/python2.7"
notice: [python-cfg] include path: "/v/pkgs/python/dep/2.7.14/include/python2.7"
notice: [python-cfg] library path: "/v/pkgs/python/dep/2.7.14/lib/python2.7/config" "/v/pkgs/python/dep/2.7.14/lib"
3) 为了验证我尝试构建以下 test.cpp
#include <Python.h>
#include <boost/python.hpp>
int main ()
{
Py_Initialize();
boost::python::object obj;
return 0;
}
使用此命令(换行以便于阅读):
g++ -g -O2
-I/v/pkgs/python/dep/2.7.14/include/python2.7
-I/v/pkgs/boost/dep/1_61_0
-L/v/pkgs/boost/dep/1_61_0/stage/lib
-lboost_python-gcc48-mt-1_61
-L/v/pkgs/python/dep/2.7.14/lib
-lpython2.7
./test.cpp
我收到以下错误:
/v/pkgs/boost/dep/1_61_0/stage/lib/libboost_python-gcc48-mt-1_61.so: undefined reference to `PyUnicodeUCS4_FromEncodedObject'
/v/pkgs/boost/dep/1_61_0/stage/lib/libboost_python-gcc48-mt-1_61.so: undefined reference to `PyUnicodeUCS4_AsWideChar'
欢迎任何提示,谢谢!
最佳答案
看来,python 不是用 UCS-4
构建的,它是用 UCS-2
构建的。
为了检查这一点,请引用 this answer 上非常相似的问题。
关于python - 针对自定义 python 构建提升,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47163112/