Subject: Re: static vs. dynamic runtime linking, again (was: PAM and su -K)
To: der Mouse <mouse@Rodents.Montreal.QC.CA>
From: Thor Lancelot Simon <tls@rek.tjls.com>
List: tech-userlevel
Date: 01/24/2005 19:48:04
On Mon, Jan 24, 2005 at 07:16:29PM -0500, der Mouse wrote:
> >> At that point I added -static and the problems went away.  [...]
> > You forgot -Wl,-rpath,/usr/X11R6/lib --
> 
> "Forgot"?  Where was I supposed to remember it from?
> 
> > there's a huge number of software packages (outside Pkgsrc) that
> > still don't get dynamic linking right.
> 
> It's hardly a "package"; it's a program of my own.
> 
> > The conclusion is that their authors should just forget
> > LD_LIBRARY_PATH + /etc/ld.so.conf and repair their build frameworks.
> 
> And just what do you think I should do to "repair" my build "framework"
> - which you, NetBSD, not I, broke?!

NetBSD didn't break anything; this is the standard way dynamic linking
works for ELF objects.  It struck me as a little bit strange too -- 10
years ago, when it was genuinely new or unusual.  Now that I've managed
to accept it as the norm, I can see that it has decided advantages (if
you read any decent explanation of ELF dependencies and runtime link
paths, and think through it for a bit, I think you will see quickly
what some of them are).

ELF doesn't work quite like a.out did in terms of loading dependencies.
In ELF, there are both a per-executable "run path" which will be searched
to find each named dependency, and, per-dependency, a name.  The run
path is explicit, and is part of the built executable; it is not
implicit in some magical way, pulled from a configuration file in
/etc, or so forth.

-R is how you set the run path in an executable.  That's all.

Thor