python - 针对自定义 python 构建提升

标签 python c++ boost-python

我正在尝试针对我的自定义 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/

相关文章:

python - 生成唯一哈希的最安全方法?

python - 无法在Docker中安装libpulse-dev

c++ - 是否可以为 std::array 定义隐式转换运算符?

c++ - 如何在不构建模块的情况下将 C++ 类公开给 Python

python - 我可以通过 Python 中的 splinter 模块以某种方式从页面上的下拉列表中选择特定元素吗

python - BeautifulSoup 返回不正确的文本

java - 用另一种语言包装 C++ 对象的策略——内存管理

c++ - 派生对象与基础对象位于同一位置

c++ - 使用 Valgrind 调试程序 - 检测段错误

python - 使用 boost python 导入