undefined reference to symbol even when nm indicates that this symbol is present in the shared library 2

蓝咒 提交于 2019-12-23 06:03:58

问题


I found same question here but the answer doesn't help me.

I'm writing test app to use nglib library. But when I try to compile it I get undefined references:

$ g++ test1.cpp -L. -lnglib
test1.cpp: In function ‘int main()’:
/tmp/cchcKZfx.o:test1.cpp:function main: error: undefined reference to 'Ng_Init()'
/tmp/cchcKZfx.o:test1.cpp:function main: error: undefined reference to 'Ng_NewMesh()'
...
/tmp/cchcKZfx.o:test1.cpp:function main: error: undefined reference to 'Ng_Exit()'
collect2: ld returned 1 exit status

but for example when I search for Ng_Init() in libnglib.so, I get positive result.

$ nm -D libnglib.so | grep Ng_Init
000000000008d0d0 T _ZN5nglib7Ng_InitEv

So I'm perplexed why I'm getting undefined reference errors ?!


回答1:


_ZN5nglib7Ng_InitEv demangles to nglib::Ng_Init() which is not the same as Ng_Init().



来源:https://stackoverflow.com/questions/15849422/undefined-reference-to-symbol-even-when-nm-indicates-that-this-symbol-is-present

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