Subject: Re: "-Ldir -lname" vs. "dir/libname.so"
To: Johnny Lam <jlam@jgrind.org>
From: Todd Vierling <tv@wasabisystems.com>
List: tech-toolchain
Date: 03/13/2002 10:53:12
On Tue, 12 Mar 2002, Johnny Lam wrote:

: Is there a difference between the following commands?
:
: (a) cc -o libbar.so.0.0 bar.o -Wl,-R/usr/pkg -L/usr/pkg -lfoo
: (b) cc -o libbar.so.0.0 bar.o -Wl,-R/usr/pkg /usr/pkg/libfoo.so

There's no difference, but you made three unrelated mistakes in these
examples:

* /usr/pkg/lib, not /usr/pkg
* the -soname argument is missing for libbar
* the -shared option is missing

: Similarly, on an a.out system, suppose I have the following files:
:
: 	/usr/pkg/lib/libfoo.so.0.0
:
: Is there a difference between the following commands?
:
: (a) ld -Bshareable -o libbar.so.0.0 bar.o -R/usr/pkg -L/usr/pkg -lfoo
: (b) ld -Bshareable -o libbar.so.0.0 bar.o -R/usr/pkg /usr/pkg/libfoo.so.0.0

`Test it.'  I believe there is a difference, but I don't have a system
available on which to check.

FROM MEMORY ONLY, may be incorrect:  The a.out linker, in case (a), will
encode a major number and minimum minor number for use by the runtime
linker.  However, if a full filename as in case (b) is given with
.major.minor, only that specific library pathname will be usable -- any
library with an incremented minor number will not link.

There's another possible difference, but you'd need to test it, as I've
never checked NetBSD's a.out linker for this:  Some linkers will encode the
full path provided in case (b) into the dependent, rather than just a
libname, resulting in a binary that has an absolute path (which would be bad
for multiple libtooled libraries built together in one tree).  In such
cases, rpath and LD_LIBRARY_PATH are unusable for finding the shared object
if it moves.

: I am trying to solve a problem involving the use of libtool in pkgsrc.

Could you describe the problem?

-- 
-- Todd Vierling <tv@wasabisystems.com>  *  Wasabi & NetBSD:  Run with it.
-- CDs, Integration, Embedding, Support -- http://www.wasabisystems.com/