我正在使用命令:
g++ --std=c++11 -fPIC -Iincludes parser.cpp lib/main-parser.o lib/lib.a
在Debian 9上编译C++程序.但是我收到以下错误消息:
/usr/bin/ld: lib/lib.a(csdocument.o): relocation R_X86_64_32 against '.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
我已经看过线程了: 编译失败时"在制作共享对象时不能使用"重定位R_X86_64_32对`.rodata.str1.8'"
但是,我尝试添加-fPIC参数,但它奇怪地给出了相同的错误消息,以及"使用-fPIC重新编译"
任何想法,将不胜感激.我已经尝试在我的大学的RedHat系统上编译它,它在那里工作正常.我认为这可能是一个缺失的依赖,但我一直无法找到任何答案.
提前致谢