relocation R_X86_64_32S against -fPIC

来源:互联网 发布:dota2多核优化启动项 编辑:程序博客网 时间:2024/06/06 12:57
/usr/bin/ld: src/common/common.o: relocation R_X86_64_32S against `.data' can not be used when making a shared object; recompile with -fPIC
src/common/common.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status

make: *** [shared] Error 1


出现这个问题是由于Makefile中的编译选项没有添加 -fPIC选项。

fPIC 作用于编译阶段,告诉编译器产生与位置无关代码(Position-Independent Code),则产生的代码中,没有绝对地址,全部使用相对地址,故而代码可以被加载器加载到内存的任意位置,都可以正确的执行。

0 0
原创粉丝点击