Subject: Re: "-Ldir -lname" vs. "dir/libname.so"
To: None <email@example.com>
From: David Laight <firstname.lastname@example.org>
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 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
In my experience, the linker doesn't treat a file found with -lfoo
any differently from one specified by its full name xxx/libfoo.so
Indeed some systems have a libc.so 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 libfoo.so.0.0 you must specify its full name.
Usually (on netbsd) libfoo.so is symlink to libfoo.so.n.n.
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: email@example.com