Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 08 Feb 2002 13:06:54 +0200
From:      Maxim Sobolev <sobomax@FreeBSD.org>
To:        Terry Lambert <tlambert2@mindspring.com>
Cc:        jdp@FreeBSD.org, deischen@FreeBSD.org, jasone@FreeBSD.org, hackers@FreeBSD.org, jlemon@FreeBSD.org
Subject:   Re: Linking libc before libc_r into application causes weird problems
Message-ID:  <3C63B14E.516941C4@FreeBSD.org>
References:  <1013147180.73417.2.camel@notebook> <3C637097.13B8C35A@mindspring.com> <3C63973F.111CF6D1@FreeBSD.org> <3C63A4C1.7C2CEEDF@mindspring.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Terry Lambert wrote:
> 
> Maxim Sobolev wrote:
> [...]
> > > Symbols are resolved from libraries in the order in which
> > > they are specified to the linker.
> > >
> > > So the fix is obvious: specify them in the right order.
> [...]
> > All not as easy as it seems to be. -lc could come not from the command
> > line, but from one of the other libraries the binary being linked
> > with. Therefore, in real life resolving this problem could be a little
> > more tricky, especially with large applications (e.g. Evolution), that
> > uses code from 30+ shared libraries. I think that ld(1) should be
> > smart enough to reorder libc/libc_r so that libc_r is always linked
> > before libc.
> 
> Excuse me.
> 
> Even assuming it were possible to order libraries so that
> certain libraries were considered "weak" and others were
> considered "strong" by their symbol tagging alone, you can
> *not* fix this wherne there are two libraries, or a mutual
> precedence order issue.
> 
> How in the heck does it get the Xll libraries linked in the
> correct -lXt -lXext -lX11 order, if not by specifying them
> in the correct order?

When you are linking with shared libraries you do not need to specify
them in the "correct" order, because AFAIK linker takes care of that
using dependency information recorded within each shared library.
Correct order only required for static libraries that do not have a
way to record a dependency information. 

-Maxim

> It's really, really stupid to make an assumption about libc_r
> that you can't even make on Linux with regards to X11/Xext/Xt,
> just because some software had the misfortune to be born on
> the wrong side of the autoconf tracks.
> 
> Code protability is an attribute of the code, not of the
> environment where the code is linked.
> 
> You might as well assume that you are going to reorder the
> dependency graph for template virtual base clases to their
> dependency order instead of their link order for something
> like ACAP (ACAP didn't used to compile with g++ until
> Jeremy Allison and I hacked it into submission, and away
> from bad assumptions, like that one, or certain spacing of
> underscores in declarations).
> 
> -- Terry

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3C63B14E.516941C4>