【发布时间】:2011-07-12 05:54:32
【问题描述】:
我正在使用 boost.python 库构建应用程序。我想链接它。代码如下:
#include <boost/python.hpp>
using namespace boost::python;
// Boost.python definitions to expose classes to Python
BOOST_PYTHON_MODULE(arrayClasses) {
}
并为其生成文件:
PYTHON = /usr/include/python2.7
BOOST_INC = /usr/include
BOOST_LIB = /usr/lib
TARGET = arrayClasses
$(TARGET).so: $(TARGET).o
g++ -shared -Wl,--export-dynamic \
$(TARGET).o -L$(BOOST_LIB) -lboost_python \
-L/usr/lib/python2.7/config -lpython2.7 \
-o $(TARGET).so
$(TARGET).o: $(TARGET).cpp
g++ -I$(PYTHON) -I$(BOOST_INC) -c -fPIC $(TARGET).cpp
当我编译它时,我得到:
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
有什么问题吗?
【问题讨论】:
标签: c++ python boost linker symbols