How can I link against libpython.a such that the runtime linker can find all the symbols in libpython.a?

时光怂恿深爱的人放手 提交于 2020-01-03 01:40:11

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!