views:

360

answers:

2

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?

+1  A: 

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.

elder_george
A: 

Updated: Thank you for your answer! But it seems that these warnings still exist.

  1. The project type was set as C++ at the beginning;

  2. Diab C++ Compiler and Diab Linker used as compiler and linker in this project. I have tried other compiler/linker such as GCC C++ compiler/linker and Cygwin C++ compiler/linker, and there are similar errors.

  3. I have added parameter -lstdc++ for compiling and linking, but it says that

    dld: error: Can't find library: libstdc++.a

Are there any other methods to solve these warnings? Thanks!

simon