【问题标题】:How can I link against libpython.a such that the runtime linker can find all the symbols in libpython.a?如何链接 libpython.a 以便运行时链接器可以找到 libpython.a 中的所有符号?
【发布时间】:2009-09-24 16:32:25
【问题描述】:

this question 的后续问题中,我的公司环境缺少libpython2.6.so 共享对象,但有libpython2.6.a 文件。有没有一种方法可以在 libpython2.6.a 中进行编译,同时保留 libpython2.6.a 中的符号,以便动态库可以在运行时找到这些符号?

我当前使用静态库的编译如下:

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

但是,如果我加载一个像“数学”这样的模块,它会死:

undefined symbol: PyInt_FromLong

【问题讨论】:

    标签: python gcc g++


    【解决方案1】:

    您需要将--export-dynamic 传递给链接器。所以来自g++ 是...

    g++ -Wl,--export-dynamic ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-17
      • 1970-01-01
      • 1970-01-01
      • 2017-02-02
      • 2015-12-23
      • 1970-01-01
      相关资源
      最近更新 更多