问题
In a sequel question to this question, my corporate environment lacks the libpython2.6.so
shared object but has the libpython2.6.a
file. Is there a way that I can compile in libpython2.6.a
while retaining the symbols in libpython2.6.a
such that dynamic libraries can find these symbols at runtime?
My current compile with the static library looks like:
g++ -I/usr/CORP/pkgs/python/2.6.2/include/python2.6 \
~/tmp.cpp -pthread -lm -ldl -lutil \
/usr/CORP/pkgs/python/2.6.2/lib/python2.6/config/libpython2.6.a \
-o tmp.exe
However, if I load a module like 'math', it dies with:
undefined symbol: PyInt_FromLong
回答1:
You need to pass --export-dynamic
to the linker. So from g++
it's...
g++ -Wl,--export-dynamic ...
来源:https://stackoverflow.com/questions/1472828/how-can-i-link-against-libpython-a-such-that-the-runtime-linker-can-find-all-the