The libstdc++ FAQ entry How do I insure that the dynamically linked library will be found links to the manual section Finding Dynamic or Shared Libraries which explains how to use RPATH instead.
My preferred method is to use an RPATH of $ORIGIN
which means that searching for dynamic library dependencies starts in the same directory as the binary (see ld.so(8)). So if you link with '-Wl,-rpath,$ORIGIN'
(note the quotes to prevent $ORIGIN being expanded by the shell) then you can install shared libraries in the same directory as your installed binary and they will be found when your binary is run. Or use '-Wl,-rpath,$ORIGIN/../lib'
if you’d rather have separate bin
and lib
directories under some installation prefix.
With the library installed alongside the binary in some custom path that ldconfig
doesn’t scan, and no LD_LIBRARY_PATH
messing up the environment, the newer libstdc++ will never be found by applications which are not supposed to use that version.
Make sure you also install the libstdc++.so.6
symlink pointing to the libstdc++.so.6.0.20
file so that the DT_NEEDED
for libstdc++.so.6
can find the file.