简体   繁体   English

如何链接到libpython.a,以便运行时链接程序可以在libpython.a中找到所有符号?

[英]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.

相关问题 Visual Studio,Marmalde C ++:导入libpython.a,在手臂上的嵌入式解释器中运行python代码 - Visual Studio, Marmalde C++: import libpython.a, run python code in embeded interpreter on arm 我在哪里可以在OSX上找到libpython2.6.dylib - where can i find libpython2.6.dylib on osx 如何找到 Python 的 libpython 所在的位置? - How do I find where Python's libpython is located? “它是如何找到 libpython 的?!” 谜 - A “how is it finding libpython?!” puzzle Python3.3在Linux(pip-3.3)中找不到libpython3.3m.so - Python3.3 can't find libpython3.3m.so in linux (pip-3.3) cython - distutils vs cmake:链接libpython? - cython - distutils vs cmake: linking against libpython? Linux上的MATLAB MEX文件无法在libpython.2.7.so中找到符号 - MATLAB MEX file on Linux fails to find symbols in libpython.2.7.so Anaconda Python virtualdev在Windows的Linux子系统上找不到libpython3.5m.so.1.0(Ubuntu 14.04) - Anaconda Python virtualdev can't find libpython3.5m.so.1.0 on Windows Subsystem for Linux (Ubuntu 14.04) 如何安装libpython2.7.so - How to install libpython2.7.so dlltool:无法创建.lib文件:libpython27.a:无效的bfd目标 - dlltool: Can't create .lib file: libpython27.a: Invalid bfd target
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM