Subject: Re: "-Ldir -lname" vs. "dir/"
To: None <>
From: David Laight <>
List: tech-toolchain
Date: 03/13/2002 11:30:21
On Tue, Mar 12, 2002 at 06:21:33PM -0600, Frederick Bruckman wrote:
> > Is there a difference between the following commands?
> >
> > (a) ld -Bshareable -o bar.o -R/usr/pkg -L/usr/pkg -lfoo
> > (b) ld -Bshareable -o bar.o -R/usr/pkg /usr/pkg/

In my experience, the linker doesn't treat a file found with -lfoo
any differently from one specified by its full name xxx/
(or xxx/libfoo.a).

Indeed some systems have a that is actually an archive
library - one of whose members is a shared library.
(Remember this is unix, the filename suffix doesn't tell you
what is in the file!)

However if you want you must specify its full name.
Usually (on netbsd) is symlink to

For ELF, the linker will do two things with a shared library:
1) mark all the symbols it defines as no longer being undefined
2) add a NEEDED entry to the elf header of the program that
   contains the SONAME of the library.

I've written shared libraries that exist only to get a specific
NEEDED entry - the ld I was using wouldn't let you create one,
dunno if the gnu one does.


David Laight: