重定位 R_X86_64_PC32 对符号 `_PyRuntime' 不能在制作共享对象时使用;使用 -fPIC 重新编译
relocation R_X86_64_PC32 against symbol `_PyRuntime' can not be used when making a shared object; recompile with -fPIC
在 64 位机器上 Python3.7 中构建库时出现以下 link 错误。
/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
的错误仍然存在
选项 1
Build/Compile Python 使用 --enable-shared
选项 2
错误建议使用-fPIC
所以可以选择
CFLAGS=-fPIC
在 make install 或[等效构建步骤]
两者都应该有效。
在 64 位机器上 Python3.7 中构建库时出现以下 link 错误。
/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.7export CFLAGS="$CFLAGS -fPIC"
但是,python3.7
的错误仍然存在选项 1
Build/Compile Python 使用 --enable-shared
选项 2
错误建议使用-fPIC
所以可以选择
CFLAGS=-fPIC
在 make install 或[等效构建步骤]
两者都应该有效。