Greetings,

In gcc-4.0.0 (and all previous releases), the C++ shared libraries (for
example) are not found without adding specific link flags.  For example,
compiling a C++ hello,world (source below, not that it matters):

$ which g++
g++ is /usr/local/gnu/bin/g++
$ g++ hello.cc
$ ldd a.out
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00599000)
        libm.so.6 => /lib/libm.so.6 (0xb7fbf000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x004f2000)
        libc.so.6 => /lib/libc.so.6 (0xb7e95000)
        /lib/ld-linux.so.2 (0x00162000)

Even though I compiled with /usr/local/gnu/bin/g++, the linker found the
stdc++ and gcc_s libraries in /usr/lib and /lib.  The resulting silent
mismatch between compiler and libraries can only cause grief for those
unaware.  To get the right thing, I have to resort to:

$ g++ -L/usr/local/gnu/lib -Wl,-R/usr/local/gnu/lib hello.cc

So, how about adding something like -L<libdir> -Wl,-R<libdir> to the
default link spec?  (And now that the specs file is no longer created by
default, still another step is required to fix this.)

The problem is not specific to C++.  It also happens with plain C and
libgcc_s, now that libgcc is (can be) shared.  I expect it happens with
other languages too, but C and C++ are all I've actually tried.

karl


#include <cstdio>
  using namespace std;

int
main ()
{
  printf ("hello, c++\n");
  return 0;
}

Reply via email to