views:

94

answers:

1

I am building a Boost Python module (.so shared library file) which depends on another external library (STXXL)

While I can build and import the example Boost Python modules, I run into problems when STXXL is thrown into the mix. Specifically when running import fast_parts in python

I get ImportError: ./fast_parts.so: undefined symbol: _ZN5stxxl10ran32StateE

This says to me that the STXXL library isn't being linked, but I am not sure how that could be as I am linking against it and the linker isn't giving me any errors. It's worth noting I can successfully build and run standalone programs using STXXL and as far as I know the libraries are stored in a .a archive in the lib directory shown below. I have reduced my Makefile down to a single command as follows:

g++ -I/home/zenna/Downloads/stxxl-1.3.0/include -include stxxl/bits/defines.h -I/home/zenna/local/include -I/usr/include/python2.6 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -O3 -Wall -g -DFOO=BAR -pthread -L/home/zenna/Downloads/stxxl-1.3.0/lib/ -lstxxl -L/home/zenna/local/lib/ -lboost_python -lpython2.6 -fPIC -shared -o fast_parts.so partition.cpp

Any advice?

A: 

I'm assuming Linux, please comment if this is incorrect. What does the ldd output for libfast_parts.so look like? Does it indicate libstxxl.so is not found?

You might need to add /home/zenna/Downloads/stxxl-1.3.0/lib/ in your LD_LIBRARY_PATH or the rpath for libfast_parts.so.

-Wl,-rpath,/home/zenna/Downloads/stxxl-1.3.0/lib -L/home/zenna/Downloads/stxxl-1.3.0/lib -lstxxl
Sam Miller
so fast_parts.so is the final output module. the ldd for it does not require libstxxl.so as libstxxl doesn't exist, the only file that does exist is stxxl.a which is a archive of .o static library files. It seems the missing symbol in question _ZN5stxxl10ran32StateE is contained with a file rand.libstxxl.o contained within the archive (found using the nm tool), but when this does not show up when I run nm on the actual archive. I'm not sure if that's relevant
zenna
Actually that's not truenm on fast_parts showed fast_part.so:0001eec0 t _GLOBAL__I__ZN5stxxl10ran32StateE
zenna
something looks strange about your link link, you might want to play around with the ordering of `-lstxxl` and whatever object files need symbols defined from it.
Sam Miller