即使nm指示该符号存在于共享库中,也未定义对符号的引用2 [英] undefined reference to symbol even when nm indicates that this symbol is present in the shared library 2
本文介绍了即使nm指示该符号存在于共享库中,也未定义对符号的引用2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我发现相同的问题,但答案并没有帮助我。
我正在编写测试应用程序以使用nglib库。但是,当我尝试编译它时,我得到未定义的引用:
$ g ++ test1.cpp -L。 -lnglib
test1.cpp:在函数'int main()'中:
/tmp/cchcKZfx.o:test1.cpp:function main:error:未定义引用'Ng_Init()'
/tmp/cchcKZfx.o:test1.cpp:function main:error:未定义引用'Ng_NewMesh()'
...
/tmp/cchcKZfx.o:test1.cpp:function main:错误:未定义引用'Ng_Exit()'
collect2:ld返回1退出状态
但是例如当我在libnglib.so中搜索Ng_Init()时,我得到了肯定的结果。
$ nm -D libnglib。所以| grep Ng_Init
000000000008d0d0 T _ZN5nglib7Ng_InitEv
所以我很困惑为什么我得到未定义的参考错误!
解决方案
_ZN5nglib7Ng_InitEv
demangles to nglib :: Ng_Init()
,它与 Ng_Init()
不一样。
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 ?!
解决方案
_ZN5nglib7Ng_InitEv
demangles to nglib::Ng_Init()
which is not the same as Ng_Init()
.
这篇关于即使nm指示该符号存在于共享库中,也未定义对符号的引用2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文