Compilation fails due to relocation error

假如想象 提交于 2020-04-30 05:10:51

问题


I'm trying to compile ANN. I compiled using the following command,

make linux-g ++

Later when I try to use this in another code, the code is not compiling. I'm getting the following error,

>  relocation R_X86_64_PC32 against symbol `_ZSt4cerr@@GLIBCXX_3.4' can
> not be used when making a shared object; recompile with -fPIC
> /usr/bin/ld: final link failed: Bad value

After going through various questions , I tried adding the following line to CMAKE,

set_target_properties(${LIBRARY_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)

but still, it doesn't work. how can I fix this?


回答1:


I'm not sure that this is a proper solution, but as a workaround, you can replace the line

"C++ = g++"

with

"C++ = g++ -fPIC"

in the file Make-config and then recompile.



来源:https://stackoverflow.com/questions/61404608/compilation-fails-due-to-relocation-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!