kirkby@t2:[~] $ ./a.out
ld.so.1: a.out: fatal: libstdc++.so.6: open failed: No such file or directory
Killed
I'm using the Sun linker, not the GNU one, so it's possible g++ is
sending stuff to the linker to indicate where the libraries are, but
the linker is ignoring them.
Ideally I'd like to send something to the Sun linker to day "look in
/usr/local/gcc-4.4.0-sun-linker/lib for libraries too"
If I set LD_LIBRARY_PATH, then this will work.
If you set LD_RUN_PATH before the compilation (more specifically, the
compile-time linking) of your program, the path from LD_RUN_PATH will
be recorded in your executable.
Recording the location of the shared libraries where they were found
during compile-time linking is not done by default because that will not
work well when you copy your executable to another machine with a different
filesystem layout, or if a newer version of the shared library is added in
a different place.