linux 生成动态库时提示relocation R_X86_64_32 against `.rodata' can not be used when making a shared object;

linux生成动态库时遇到了relocation R_X86_64_32 against `.rodata‘ can not be used when making a shared object; recompile with -fPIC错误。

由于我的系统是AMD64位的,所以需要在编译的时候添加 -fPIC选项


解决方法:

例如:

g++ -c -fPIC head.cpp    生成head.o

g++ -fpic -shared -o libfun.so head.o 

linux 生成动态库时提示relocation R_X86_64_32 against `.rodata' can not be used when making a shared object;,布布扣,bubuko.com

linux 生成动态库时提示relocation R_X86_64_32 against `.rodata' can not be used when making a shared object;

上一篇:Xshell链接错误:Could notconnect to '192.168.18.128' (port 22): Connection failed.


下一篇:Linux下安装并配置VSCode(Visual Studio Code)