Bug 50250 - Driver documentation on -l does not mention shared libraries
Driver documentation on -l does not mention shared libraries
Status: UNCONFIRMED
Product: gcc
Classification: Unclassified
Component: driver
4.7.0
: P3 minor
: ---
Assigned To: Not yet assigned to anyone
: documentation
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-08-31 12:21 UTC by Richard Biener
Modified: 2011-08-31 12:21 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2011-08-31 12:21:39 UTC
Forwarded from http://bugzilla.novell.com/show_bug.cgi?id=674696

The documentation says

-----------
@cindex Libraries
@item -l@var{library}
@itemx -l @var{library}
@opindex l
Search the library named @var{library} when linking.  (The second
alternative with the library as a separate argument is only for
POSIX compliance and is not recommended.)

It makes a difference where in the command you write this option; the
linker searches and processes libraries and object files in the order they
are specified.  Thus, @samp{foo.o -lz bar.o} searches library @samp{z}
after file @file{foo.o} but before @file{bar.o}.  If @file{bar.o} refers
to functions in @samp{z}, those functions may not be loaded.

The linker searches a standard list of directories for the library,
which is actually a file named @file{lib@var{library}.a}.  The linker
then uses this file as if it had been specified precisely by name.

The directories searched include several standard system directories
plus any that you specify with @option{-L}.

Normally the files found this way are library files---archive files
whose members are object files.  The linker handles an archive file by
scanning through it for members which define symbols that have so far
been referenced but not defined.  But if the file that is found is an
ordinary object file, it is linked in the usual fashion.  The only
difference between using an @option{-l} option and specifying a file name
is that @option{-l} surrounds @var{library} with @samp{lib} and @samp{.a}
and searches several directories.
--------

note how it specifically mentions -lX searches for libX.a.  But:

gcc t.c -lX

also finds libX.so which it should not, according to the above documentation.

The documentation should be clarified and refer to whatever used target linker
documentation.