/usr/bin/ld: /usr/local/python3.12/lib/libpython3.12.a(string_parser.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC collect2: error: ld returned 1 exit status apxs:Error: Command failed with rc=65536 . make: *** [Makefile:31:src/server/mod_wsgi.la] 错误 1
遇到的这个报错是编译 mod_wsgi 时链接阶段的 PIC 编译标志不兼容问题,核心原因是:你系统中 /usr/local/python3.12 下的 Python 3.12 是通过静态库(libpython3.12.a)编译的,且编译时未启用 -fPIC 标志,而 mod_wsgi 作为 Apache 的动态共享模块(.so),链接时必须依赖启用了 PIC 编译的 Python 库(静态库 / 动态库均可,核心是带 -fPIC),静态库缺少该标志会直接导致链接器(ld)报错终止。
一、核心报错拆解
relocation R_X86_64_32 against '.rodata.str1.1' can not be used when making a shared object:64 位系统中,构建动态共享模块时,所有参与链接的库文件必须支持位置无关代码(Position-Independent Code,PIC),否则无法完成地址重定位,这是 64 位系统编译动态模块的硬性要求;recompile with -fPIC:链接器明确提示解决方案 —— 重新编译 Python 并添加-


206

被折叠的 条评论
为什么被折叠?



