shared library locations

Andrew Pinski pinskia@physics.uc.edu
Mon Apr 25 19:51:00 GMT 2005


On Apr 25, 2005, at 11:59 AM, Karl Berry wrote:

> 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

-Wl,-R is bad, I repeat bad.

Set LD_LIBRARY_PATH as directed on the libstdc++ installation 
instructions:
http://gcc.gnu.org/onlinedocs/libstdc++/install.html



-- Pinski



More information about the Gcc-bugs mailing list