[英]How can I link against libpython.a such that the runtime linker can find all the symbols in libpython.a?
In a sequel question to this question , my corporate environment lacks the libpython2.6.so
shared object but has the libpython2.6.a
file. 在此问题的后续问题中,我的公司环境缺少
libpython2.6.so
共享库,但具有libpython2.6.a
文件。 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? 有没有一种方法可以在
libpython2.6.a
进行编译,同时将符号保留在libpython2.6.a
,以便动态库可以在运行时找到这些符号?
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
You need to pass --export-dynamic
to the linker. 您需要将
--export-dynamic
传递给链接器。 So from g++
it's... 所以从
g++
开始
g++ -Wl,--export-dynamic ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.