Inconsistent library behaviour between gcc and g++

Michael Eager eager@eagercon.com
Sat Oct 7 23:27:00 GMT 2006


Andrew Haley wrote:
> This should have been sent to gcc-help.  I'm redirecting this reply.
> 
> nahthan writes:
>  > How can a self contained gcc and g++ be created such that behaviour between
>  > gcc and g++ is consistent without having to set setting LD_LIBRARY_PATH?
>  > 
>  > Test system: Linux 2.4.32 #1 SMP Tue Aug 8 10:17:37 PDT 2006 i686 i686
>  > i386 GNU/Linux
>  > 
>  > g++ breaks on libstdc++.so.*
>  > gcc appears to be fine.
> 
> Because you have libc but not libstdc++.so.6 installed in /lib/.
> 
> If you have a look at the man page for ld.so you will see that it
> looks in a number of pre-specified places for libraries.  If you put
> libstdc++ in one of those it will be found.  Otherwise you'll need
> either to set LD_LIBRARY_PATH or use the -rpath linker command.
> 
>  > Why am I forced to set the library path with g++ but not gcc?
>  > This is inconsistent and confusing.  Why don't the resulting binaries look in
>  > --with-local-prefix or --prefix library paths at runtime?
> 
> The binaries don't look anywhere: it's ld.so that does the lookup, and
> it is not part of gcc.

You can add libraries to the loader search list.

See "man ldconfig".

-- 
Michael Eager	 eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077



More information about the Gcc-help mailing list