Cha*_*pat 2 c python python-3.x python-3.7
在 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
Run Code Online (Sandbox Code Playgroud)
在同一台计算机上,如果我安装 miniconda https://docs.conda.io/en/latest/miniconda.html [Py 3.8 for 64bit],该库可以在该 conda 环境中正常安装,不会出现任何错误。
我尝试通过添加构建 Py3.7
export CFLAGS="$CFLAGS -fPIC"
Run Code Online (Sandbox Code Playgroud)
但是,对于python3.7,错误仍然存在
使用构建/编译Python--enable-shared
错误建议使用-fPIC
所以人们可以选择
CFLAGS=-fPIC
Run Code Online (Sandbox Code Playgroud)
在 make install 或 [等效的构建步骤]
两者都应该有效。