Subject: Re: Why -Wl,-R ?
To: Thomas Klausner <email@example.com>
From: Frank van der Linden <firstname.lastname@example.org>
Date: 12/23/1999 01:28:34
On Thu, Dec 23, 1999 at 01:12:09AM +0100, Thomas Klausner wrote:
> I was wondering why, when linking on an ELF-system, I have to add both
> the -L/path and -Wl,-R/path to the linker's commandline. In the
> linking step it has to find the library anyway, so the linker could
> just add the directory where it found the library to the executables
> internal search path -- or what am I missing?
There are situations where you might want to link to a library of which
you know that it will eventually end up in another place. For example,
you have a package which consists of some libraries, and some programs.
You first compile the libraries, which reside in, say, foo/src/lib,
and then you link the programs, which might be in foo/src/prog. You
specify -L../lib, because that's where the libs currently are. You
use -Wl,-R/usr/pkg/lib, because that's where the libraries will be
installed. It's the difference between current location and runtime
location that's important here.