Subject: Re: "-Ldir -lname" vs. "dir/libname.so"
To: Johnny Lam <jlam@jgrind.org>
From: Nick Hudson <skrll@netbsd.org>
List: tech-toolchain
Date: 03/13/2002 00:40:21
On Tuesday 12 March 2002 11:04 pm, Johnny Lam wrote:
> On an ELF system, suppose I have the following files:
> 
> 	/usr/pkg/lib/libfoo.so
> 	/usr/pkg/lib/libfoo.so.0
> 	/usr/pkg/lib/libfoo.so.0.0
> 
> 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

(I guess you mean cc -shared.)  I very much doubt it. The linker will extract 
the soname from the library that is found and add it to the NEEDED list.

> 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

Don't know.

> I am trying to solve a problem involving the use of libtool in pkgsrc.
> It's unclear to me if directly naming the shared library in (b) will always
> work while the use of "-Ldir -lname" in (a) is generally accepted across
> most compilers.  So will (b) always work when using GCC, or only when
> using NetBSD?

Sorry I haven't replied yet. I've been thinking about it. The problem is I've 
not come to any real conclusions yet. The whole libtool relinking thing is 
not something I claim to understand and, although, I believe the code that 
you've highlighted as being the problem is probably wrong, I cannot be sure.

Let me think about it some more...

>  I've tried querying the libtool mailing list, but I've not
> heard any response yet.

I wouldn't hold your breath. :)

Nick