Help: LD_LIBRARY_PATH needed for gcc to find libgcc_s.so.1

Andrew Walrond andrew@walrond.org
Tue May 25 10:29:00 GMT 2004


Compile a simple c++ test program:

$ gcc -lstdc++ test.cpp
/bin/ld: warning: libgcc_s.so.1, needed 
by /pkg/gcc.2/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/libstdc++.so, not found 
(try using -rpath or -rpath-link)
/pkg/gcc.2/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/libstdc++.so: undefined 
reference to `_Unwind_DeleteException@GCC_3.0'
...etc etc

So it can't find 'libgcc_s.so.1'.

$ find /pkg/gcc.2/lib -name libgcc_s.so.1
/pkg/gcc.2/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/libgcc_s.so.1

But,

$ gcc -print-search-dirs
install: /pkg/gcc.2/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/
programs: 
=/pkg/gcc.2/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/:/pkg/gcc.2/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/:/pkg/gcc.2/lib/gcc-lib/i686-pc-linux-gnu/:/usr/lib/gcc/i686-pc-linux-gnu/3.3.3/:/usr/lib/gcc/i686-pc-linux-gnu/:/pkg/gcc.2/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/../../../../i686-pc-linux-gnu/bin/i686-pc-linux-gnu/3.3.3/:/pkg/gcc.2/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/../../../../i686-pc-linux-gnu/bin/
libraries: 
=/pkg/gcc.2/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/:/usr/lib/gcc/i686-pc-linux-gnu/3.3.3/:/pkg/gcc.2/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/../../../../i686-pc-linux-gnu/lib/i686-pc-linux-gnu/3.3.3/:/pkg/gcc.2/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/../../../../i686-pc-linux-gnu/lib/:/pkg/gcc.2/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/../../../i686-pc-linux-gnu/3.3.3/:/pkg/gcc.2/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/../../../:/lib/i686-pc-linux-gnu/3.3.3/:/lib/:/usr/lib/i686-pc-linux-gnu/3.3.3/:/usr/lib/

So it's in the library search path. Hmmm. Try LD_LIBRARY_PATH:

$ export LD_LIBRARY_PATH=/pkg/gcc.2/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/
$ gcc -lstdc++ test.cpp
$

It works... but why doesn't it work without LD_LIBRARY_PATH?

gcc was configured with

configure --prefix='/pkg/gcc.1'
	--libexecdir='/pkg/gcc.1/bin/libexec'
	--datadir='/pkg/gcc.1/share'
	--includedir='/pkg/gcc.1/include'
	--infodir='/pkg/gcc.1/info'
	--mandir='/pkg/gcc.1/man'
	--sysconfdir='/pkg/gcc.1/etc/gcc'
	--localstatedir='/pkg/gcc.1/state'
	--host=i386-pc-linux-gnu
	--enable-shared
	--disable-checking
	--enable-threads=posix
	--enable-languages=c,c++
	--with-system-zlib
	--enable-long-long
	--enable-clocale=generic
	--enable-__cxa_atexit
	--enable-version-specific-runtime-libs



More information about the Gcc mailing list