dimanche 28 juin 2015

g++ fails with "undefined reference" errors to the standard C++ library

I have built and installed g++ and tested it on a simple "Hello World" program and it appears to work.

However, for our larger code, the compile fails with errors such as:

CMakeFiles/gaim_convert.dir/GaimConvert.cpp.o: In function Output(std::string const&, std::ostream&)':GaimConvert.cpp:(.text._Z6OutputRKSsRSo[_Z6OutputRKSsRSo]+0x12): undefined reference tostd::basic_ostream >& st d::__ostream_insert >(std::basic_ostream >&, char const*, long)'

The program that works correctly is:

#include <iostream>

int main() {
  std::cout << "Hello World!" << std::endl;
  std::cin.get();
  return 0;
}

So clearly certain parts of the C++ standard library are installed correctly. This is not simply an "obvious" installation bug that does not have libstdc++ installed.

The code will compile with a different version of the compiler, so it's not the code.

What is a way to debug the installation so that this error message is removed? The library path is LD_LIBRARY_PATH:

/tec/mannucci/gccBuild/lib64:/tec/mannucci/gccBuild/lib:/usr/local/gmp510/lib:/usr/local/mpfr311/lib:/usr/local/mpc101/lib:/usr/local/ppl011/lib:/usr/local/cloog0162/lib:/usr/local/lib64:/usr/lib64:...

Thank you.

-Tony

Aucun commentaire:

Enregistrer un commentaire