使用Eclipse链接C ++项目时未定义的符号错误 [英] Undefined symbol errors when linking of C++ project using Eclipse
问题描述
类型1:
dld :警告:未定义的符号**'__ record_needed_destruction'**在文件'./xxx/xx.o'
dld:warning:未定义的符号**'__ memzero'**在文件'./xxx/xyy.o '
dld:warning:未定义的符号**'__ vec_delete'**在文件'./xxx/xyz.o'
dld:warning:未定义的符号**'__ vec_new'**在文件'。 /xxx/yy/xxx/yyy.o'
dld:warning:未定义的符号**'__ pure_virtual_called'**在文件'./xxx/zzz.o'
关键是这些符号在源代码中没有使用。什么是确切的手段呢?
类型2:
dld:warning:文件'./xxx/x1.o','./xxx/x2.o','./xxx/x3.o'中的未定义符号:
nothrow__3std
** std :: nothrow **
源代码如下:
ApplicationSystem * pApplicationSystem = ** new(std :: nothrow)** ApplicationSystem {
.....
.....
}
类似的语句出现在3个cpp文件中。 std :: nothrow?
编译器构建后,您的对象文件(.o)链接器需要链接并替换所有符号名称(例如函数调用)与库中的地址。但是在你的情况下,他无法解决这个地址。
似乎你没有在图书馆中提到stdc ++。
可能需要将项目类型设置为C ++,或将编译器名称设置为g ++而不是gcc,或者将参数-lstdc ++添加到命令行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 strange. 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.
这篇关于使用Eclipse链接C ++项目时未定义的符号错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!