Undefined symbol errors when linking of C++ project using Eclipse
I compiled one C++ project which transplanted from another project, and there are some undefined symbol warnings while linking after compiled. The point is that these warnings are so strang开发者_如何学Ce. They are divided into 2 types:
Type 1:
dld: warning: Undefined symbol **'__record_needed_destruction'** in file './xxx/xx.o'
dld: warning: Undefined symbol **'__memzero'** in file './xxx/xyy.o'
dld: warning: Undefined symbol **'__vec_delete'** in file './xxx/xyz.o'
dld: warning: Undefined symbol **'__vec_new'** in file './xxx/yy/xxx/yyy.o'
dld: warning: Undefined symbol **'__pure_virtual_called'** in file './xxx/zzz.o'
The key point is that these symbols were not used in the source code. What is exact means of there warings?
Type 2:
dld: warning: Undefined symbol in file './xxx/x1.o', './xxx/x2.o', './xxx/x3.o':
nothrow__3std
**std::nothrow**
The source code is below:
ApplicationSystem* pApplicationSystem = **new(std::nothrow)** ApplicationSystem{
.....
.....
}
The similar statements appear in 3 cpp files.Is there something wrong about the use of std::nothrow?
After compiler built your object files (.o) linker needs to link them and replace all symbol names (e.g. function calls) with addresses from libraries. But in your case he can't resolve this addresses.
It seems that you haven't mentioned stdc++ among libraries.
Probably, you'll need to set project type as C++, or set compiler name to g++ instead of gcc, or add parameter -lstdc++ to command line eclipse uses for build.
精彩评论