c++ runtime "symbol lookup error"
2015-01-19 10:50
776 查看
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:
./TestCppProgram: symbol lookup error: ./TestCppProgram:
undefined symbol: _ZN12CppProgramC1Ev
I searched the internet.
Two of the interesting links I found were the following: 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 theLD_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.)
I was working on a c++ project. Everything linked and compiled fine. Upon running the executable, I got the following error:
./TestCppProgram: symbol lookup error: ./TestCppProgram:
undefined symbol: _ZN12CppProgramC1Ev
I searched the internet.
Two of the interesting links I found were the following: 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 theLD_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.)
相关文章推荐
- c++ runtime symbol lookup error
- C/C++中的 error LNKxxxx: unresolved external symbol "xxxxx"
- "symbol lookup error"问题解决
- C++ 遇到error LNK2019: unresolved external symbol "public: void __thisca的问题
- 关于"symbol lookup error xxxxx , undefined symbol"问题的解决方式
- runtime:symbol lookup error,:undefined symbol :stat
- symbol lookup error"问题
- "symbol lookup error"问题解决
- C和C++混合编程中出现error LNK2001: unresolved external symbol "void __cdecl av_free(void *)" (?av_free@@YAXP
- 关于"error LNK2019: unresolved external symbol _SipShowIM referenced in function "protected" 解决方法
- configure: error: C++ preprocessor "/lib/cpp" fails sanity check
- perl: symbol lookup error: /usr/local/lib/libtdsodbc.so: undefined symbol: libiconv_open的解决办法
- DSP 由C升级至C++的错误error: symbol referencing errors 解决办法.
- 打开word或者office程序报错:Microsoft Visual C++ Runtime Library. Runtime Error!
- configure: error: C++ preprocessor "/lib/cpp" fails sanity check
- configure: error: C++ preprocessor "/lib/cpp" fails sanity check
- error LNK2019: unresolved external symbol "public 错误的出现原因.
- configure: error: C++ preprocessor "/lib/cpp" fails sanity check-centos5安装mysql报错!
- error LNK2001: unresolved external symbol "void __stdcall _com_issue_error (long)"
- VC,link error,ATL 链接错误"unresolved external symbol _main"