Dynamic linker is unable to find GCC libraries
Benoit Hudson
bhudson@ptolemy.arc.nasa.gov
Wed Jul 5 16:01:00 GMT 2000
On Wed, Jul 05, 2000 at 07:08:16PM -0300, Alexandre Oliva wrote:
> On Jul 5, 2000, Benoit Hudson <bhudson@ptolemy.arc.nasa.gov> wrote:
>
> > we don't pass -R to the linker because your program might hang even
> > if it isn't using the library.
> > Is easily refuted by:
> > every C++ program uses libstdc++.
>
> That's not true. Why do you think so?
Because of
> LD_LIBRARY_PATH=
> echo "int main() { return 0; }" > foo.cc
> g++ foo.cc
> ./a.out
ld.so.1: ./a.out: fatal: libstdc++.so.2.10.0: open failed: No such
file or directory
So I suppose I should have specified 'every c++ program _compiled_with_g++_
uses libstc++'
I should also have specified that this occurs using gcc-2.95.2 on Solaris
2.6 and on linux (RedHat 6.1).
Using gcc 2.8.1 on the Solaris 2.6 box, I can't link foo.cc; but if I set
LD_LIBRARY_PATH, link, unset, and run, it works. ldd doesn't show a.out
depending on libstdc++.
> The usual recommended fix for this problem is to add the directory
> containing libstdc++ to /etc/ld.so.conf, so that users don't have to
> bother to add it to their own LD_LIBRARY_PATHs.
> Another option for you is to set the environment variable LD_RUN_PATH
> so that, whenever you link a program, the directories listed in this
> variable will be encoded in the executable, and, when it's run,
> they'll be searched.
Except both these mean it'll be added to non-c++ programs too, right? I
agree that it's not useful to add the -R flag to gcc in general, I only
claim it is required for [cg]++.
> Yet another option is to change the SONAME of libstdc++.so so that it
> becomes the its full pathname. But then, you won't be allowed to move
> libstdc++.so to another directory, ever.
Even less palatable, as you point out. I've had to fix enough old binaries
whose libraries went away to know that hard-coding the filename would be
bad.
-- Benoit
More information about the Gcc-bugs
mailing list