c++ runtime symbol lookup error
来源:互联网 发布:车管家软件 编辑:程序博客网 时间:2024/06/06 01:49
今天编程遇到问题,我对一个类不加namespace的时候是对的,运行完全正确。可是我加上namespace的时候,编译都对,但是就是运行时出错:
../bin/test_gbr: symbol lookup error: ../bin/test_gbr: undefined symbol: _ZN3gbr9ksdensityC1EPKdiiSsSs。
我以为是namespace的名字有冲突,就改了个名字,发现还是一样错。然后测试其它同样有namespace的类,没有问题,单单这个类有问题。
找同学帮忙,google了一下,“namespace class symbol lookup error c++",第一条就是答案:http://gdwarner.blogspot.com/2009/03/c-runtime-symbol-lookup-error.html.
转载全文如下:
c++ runtime "symbol lookup error"
I was working on a c++ project. Everything linked and compiled fine. Upon running the executable, I got the following error:
I searched the internet. Two of the interesting links I found were the following:./TestCppProgram: symbol lookup error: ./TestCppProgram: undefined symbol: _ZN12CppProgramC1Ev
- http://osdir.com/ml/gcc.g++.general/2005-02/msg00061.html
- http://www.linuxquestions.org/questions/linux-software-2/undefined-symbol-cout-263568/
For me it ended up being a bad LD_LIBRARY_PATH. The path I intended the executable to find it's needed shared library was in the LD_LIBRARY_PATH, it just wasn't before a different path which had an older version of the needed shared library. (This happened to me when I updated by bashrc with a library path and just re-sourced it).
Some cool commands in the debugging process:
- ldd TestCppProgram (Shows you where your program is getting it's libraries from. An early-on careful inspection of this would've quickly let me to my problem!)
- ldd -d -r TestCppProgram (Shows you any undefined symbols. There shouldn't be any undefined symbols for an executable, but there will be for a shared lib if it depends on another shared lib. Somebody please correct me if I'm wrong)
- nm TestCppProgram | c++filt (displays unmangled symbol information)
- nm TestCppProgram (Displays mangled symbol information. Ie: You should be able to find stuff like ZN12CppProgramC1Ev in here. In my problem above, I found which line number the undefined symbol in question was on, and then looked it up in the unmangled version to see what function it was trying to resolve. It let me know, but it didn't really help me find out what my problem was.)
- readelf -d TestCppProgram (Shows library dependencies. similar to ldd.)
发现我的问题与作者是一样的。我的gbr需要编译成shared library,然后我会安装到$USR_LIB这个我自己的目录下。但是每次我重新编译gbr时,新生成的libgbr.so在本地目录,并没有自动安装到$USR_LIB目录下,因而$USR_LIB里的libgbr.so一直是旧的,就是没有用namespace的情况。在运行可执行文件时,系统自动找到$USR_LIB里的libgbr.so并未更新,所以每次都会出错。
问题找到了,解决办法很简单,更新$USR_LIB里的libgbr.so为最新编译的。然后测试,运行正确。
- c++ runtime symbol lookup error
- c++ runtime "symbol lookup error"
- runtime:symbol lookup error,:undefined symbol :stat
- symbol lookup error - undefined symbol
- symbol lookup error: undefined symbol
- symbol lookup error: undefined symbol
- "symbol lookup error"问题解决
- "symbol lookup error"问题解决
- symbol lookup error"问题
- symbol lookup error错误
- symbol lookup error
- git: symbol lookup error: git:undefine symbol ...
- symbol lookup error,undefined symbol: pthread_create
- symbol lookup error:undefined symbol: libssh2_init
- psql error: psql: symbol lookup error: psql: undefined symbol: PQconnectdbParams
- jni运行错误 symbol lookup error
- ubuntu14.04 出现symbol lookup error
- symbol lookup error: /usr/bin/suricata: undefined symbol: htp_config_set_query_case_insensitive 解决方法
- 金蝶EAS登陆客服端时报错
- pku 2446
- ffmpeg编码参数初始化
- 显示器黑屏故障分析
- VB无所不能之四:制作透明和半透明窗体
- c++ runtime symbol lookup error
- .net3.5 和vs2008中Ajax控件的使用--Accordion(可折叠)控件
- Sql Server 对xml类型的操作
- 用std::find查找文件流中的内容
- WINDOWS目录
- 整型计算器
- java.lang.UnsupportedClassVersionError: com/kingdee/eas/basedata/org/OrgType (Unsupported major.minor version 49.0)的解决
- 触发器的创建
- h264获取视频流信息- 复用h264字节流文件代码在RawH264File2Ts函数里面