我试图在Ubuntu Linux上使用CMake编译软件,但出现以下错误:
[ 71%] Linking CXX executable convert_imageset
/usr/local/lib/libboost_python.so: undefined reference to `PyString_Size'
/usr/local/lib/libboost_python.so: undefined reference to `PyString_FromStringAndSize'
/usr/local/lib/libboost_python.so: undefined reference to `PyString_FromString'
/usr/local/lib/libboost_python.so: undefined reference to `PyInt_Type'
/usr/local/lib/libboost_python.so: undefined reference to `PyInt_FromLong'
/usr/local/lib/libboost_python.so: undefined reference to `PyFile_FromString'
/usr/local/lib/libboost_python.so: undefined reference to `PyNumber_Divide'
/usr/local/lib/libboost_python.so: undefined reference to `PyUnicodeUCS4_FromEncodedObject'
/usr/local/lib/libboost_python.so: undefined reference to `PyNumber_InPlaceDivide'
/usr/local/lib/libboost_python.so: undefined reference to `PyString_InternFromString'
/usr/local/lib/libboost_python.so: undefined reference to `PyUnicodeUCS4_AsWideChar'
/usr/local/lib/libboost_python.so: undefined reference to `PyInt_AsLong'
/usr/local/lib/libboost_python.so: undefined reference to `PyString_AsString'
/usr/local/lib/libboost_python.so: undefined reference to `PyString_FromFormat'
/usr/local/lib/libboost_python.so: undefined reference to `PyClass_Type'
/usr/local/lib/libboost_python.so: undefined reference to `PyFile_AsFile'
/usr/local/lib/libboost_python.so: undefined reference to `Py_InitModule4_64'
/usr/local/lib/libboost_python.so: undefined reference to `PyString_Type'
collect2: error: ld returned 1 exit status
我的理解是,链接器失败,因为/usr/local/lib/libboost_python.so
lib不包含提到的符号。但是我可以看到提到的符号在库中显示:
wakatana@machine:~$ nm -D /usr/local/lib/libboost_python.so | egrep 'PyString_Size|PyString_FromStringAndSize|PyString_FromString|PyInt_Type|PyInt_FromLong|PyFile_FromString'
U PyFile_FromString
U PyInt_FromLong
U PyInt_Type
U PyString_FromString
U PyString_FromStringAndSize
U PyString_Size
我在这里想念的东西。如何调试这些类型的错误?