Reputation: 4558
I want to build this openNERO for myself. According to its building tutorial, I also build Boost 1.48 with python 2.7.2. With Boost, openNERO is compiled successfully. But when it try to link, ld
complains that
CMakeFiles/OpenNERO.dir/scripting/scripting.cpp.o: In function `initOpenNero':
~/svn/opennero/trunk/source/scripting/scripting.cpp:21: undefined reference to `boost::python::detail::init_module(char const*, void (*)())'
/usr/local/lib/libboost_python.so: undefined reference to `PyModule_Create2'
/usr/local/lib/libboost_python.so: undefined reference to `PyBytes_AsString'
/usr/local/lib/libboost_python.so: undefined reference to `PyBytes_Size'
/usr/local/lib/libboost_python.so: undefined reference to `_PyUnicode_AsString'
/usr/local/lib/libboost_python.so: undefined reference to `PyUnicode_InternFromString'
collect2: ld returned 1 exit status
Can anyone give hints for me on this issue? Thank you~
UPDATE 1: [Removed]
UPDATE 2: Thanks for this post. I use nm
to check the signature of init_module
, yet it prints:
$nm libboost_python.so.1.48.0 |c++filt|grep init_module
0002e710 T boost::python::detail::init_module(PyModuleDef&, void (*)())
Here is the snippet from the source file:
# if PY_VERSION_HEX >= 0x03000000
BOOST_PYTHON_DECL PyObject* init_module(PyModuleDef&, void(*)());
# else
BOOST_PYTHON_DECL PyObject* init_module(char const* name, void(*)());
# endif
So it is of Python 3.x. But I did build Boost with parameter --with-python-version=2.7
. Moreover, I use update-alternatives
to choose Python 2.7. So why is the PY_VERSION_HEX
still not correct?
Upvotes: 1
Views: 4648
Reputation: 4558
I remember I first built boost with python 3.2, so I deleted all the files generated and rebuilt boost again. This time everything is correct. It seems that the older files will not be overwritten.
Upvotes: 1