【问题标题】:relocation R_X86_64_PC32 against symbol `_PyRuntime' can not be used when making a shared object; recompile with -fPIC重定位 R_X86_64_PC32 对符号 `_PyRuntime' 在制作共享对象时不能使用;使用 -fPIC 重新编译
【发布时间】:2020-10-08 04:08:22
【问题描述】:

在 64 位机器上使用 Python3.7 构建库时出现以下链接错误。

 /usr/bin/ld: /usr/local/lib/libpython3.7m.a(ceval.o): relocation R_X86_64_PC32 against symbol `_PyRuntime' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: final link failed: Bad value
    collect2: error: ld returned 1 exit status

在同一台机器上,如果我安装一个 miniconda https://docs.conda.io/en/latest/miniconda.html [Py 3.8 for 64bit],该库在该 conda 环境中安装良好,没有任何错误。

我尝试通过添加来构建 Py3.7

export CFLAGS="$CFLAGS -fPIC"

但是,python3.7 的错误仍然存​​在

【问题讨论】:

    标签: python c python-3.x python-3.7


    【解决方案1】:

    选项 1

    使用 --enable-shared 构建/编译 Python

    选项 2

    错误提示使用-fPIC 所以可以选择

    CFLAGS=-fPIC
    

    在 make install 或 [等效的构建步骤]

    两者都应该工作。

    【讨论】:

    • cxxflags=-fPIC cflags=-fPIC这个怎么用,看不懂。像这样:export cflags=-fPIC ; export cxxflags=-fPIC; make altinstall?
    • 想通了:export CFLAGS=-fPIC ; ./configure --enable-loadable-sqlite-extensions --enable-optimizations make altinstall 谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-05-17
    • 2021-01-17
    • 2016-06-06
    • 2017-05-22
    • 1970-01-01
    • 2017-07-23
    • 1970-01-01
    相关资源
    最近更新 更多