python - Linker error with libboost_python-py34 on Ubuntu 15.04 -


i must making simple mistake trying use boost-python on ubuntu linux 15.04 (vivid vervet), libboost-python1.55-dev package installed.

i'm trying build simple test file so:

$ g++ -o conftest -wall -i/usr/include/python3.4m -i/usr/include/x86_64-linux-gnu/python3.4m  -l/usr/lib/x86_64-linux-gnu -lboost_python-py34 -lpython3.4m conftest.cc 

but gives me linker error:

/tmp/ccxkw5xr.o: in function `pyinit_test': conftest.cc:(.text+0x7e): undefined reference `boost::python::detail::init_module(pymoduledef&, void (*)())' collect2: error: ld returned 1 exit status 

but symbol seem exist:

$ nm -d --demangle /usr/lib/x86_64-linux-gnu/libboost_python-py34.so | grep "init_module" 0000000000033ac0 t boost::python::detail::init_module(pymoduledef&, void (*)()) 

this simple test code i'm building, based on config test used ax_boost_python autoconf macro:

#include <boost/python/module.hpp>  boost_python_module(test) { throw "boost::python test."; }  int main () {   return 0; } 

can see i'm doing wrong?

the first thing stuck out me in compiler invocation you've listed libraries before source file uses them on command line.

this work anyway shared libraries, isn't strictly correct. instance, it'll break if you're using static libraris, since objects archive needed satisfy symbols things earlier in command line included. seems make difference here, though we're using shared libraries:

$ g++ -o conftest -wall -i/usr/include/python3.4m -i/usr/include/x86_64-linux-gnu/python3.4m  -l/usr/lib/x86_64-linux-gnu -lboost_python-py34 -lpython3.4m conftest.cc /tmp/ccj8znlk.o: in function `pyinit_test': conftest.cc:(.text+0x7e): undefined reference `boost::python::detail::init_module(pymoduledef&, void (*)())' collect2: error: ld returned 1 exit status $ g++ -o conftest -wall -i/usr/include/python3.4m -i/usr/include/x86_64-linux-gnu/python3.4m  -l/usr/lib/x86_64-linux-gnu conftest.cc -lboost_python-py34 -lpython3.4m $ ldd conftest | grep python     libboost_python-py34.so.1.55.0 => /usr/lib/x86_64-linux-gnu/libboost_python-py34.so.1.55.0 (0x00007f6291003000)     libpython3.4m.so.1.0 => /usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0 (0x00007f62909c2000) 

the second g++ invocation succeeds , produces correctly linked executable.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -