Ld错误符号

2024-10-01 07:38:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在用构建应用程序boost.python图书馆。我想把它联系起来。代码如下:

#include <boost/python.hpp>
using namespace boost::python;

// Boost.python definitions to expose classes to Python
BOOST_PYTHON_MODULE(arrayClasses) {
}

并为其生成文件:

^{pr2}$

当我编译它时,我得到:

g++ -shared -Wl,--export-dynamic \
    arrayClasses.o -L/usr/lib -lboost_python \
    -L/usr/lib/python2.7/config -lpython2.7 \
    -o arrayClasses.so
/usr/bin/ld: arrayClasses.o: relocation R_X86_64_32 against `init_module_arrayClasses()' can not be used when making a shared object; recompile with -fPIC
arrayClasses.o: could not read symbols: Bad value
collect2: ld returned 1 exit status

怎么了?在


Tags: to代码应用程序图书馆includelibusrnot
1条回答
网友
1楼 · 发布于 2024-10-01 07:38:41

You have -fPIC for your .o target, but not for the .so target. See if adding it helps.

编辑:忽略它。这是在一个32位的Ubuntu系统上用python2.6和boost1.44编译的。正如ignaciovazquez-Abrams所指出的,您可能应该检查一下Python和Boost库是否是为相同的架构编译的。在

相关问题 更多 >