Linking a static library to Python Boost (shared library) - Import error

I am creating a Python Boost module (shared library file) that depends on another external library (STXXL)

While I can create and import Python Boost modules, I run into problems when STXXL is thrown into the mix. In particular, when running import fast_partsin python

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

This tells me that the STXXL library is not linked, but I'm not sure how it can be, since I am linking to it and the linker is not giving me any errors. It is worth noting that I can successfully create and run standalone programs using STXXL, and as far as I know, the libraries are stored in the .a archive in the lib directory shown below. I reduced my Makefile to one 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 tips?

+2
source share
1 answer

I assume Linux, comment if this is not true. What does the output look like lddfor libfast_parts.so? Does this mean that it is libstxxl.sonot found?

You may need to add /home/zenna/Downloads/stxxl-1.3.0/lib/to your LD_LIBRARY_PATHor 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
0
source

Source: https://habr.com/ru/post/1760539/


All Articles