http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50250
Bug #: 50250 Summary: Driver documentation on -l does not mention shared libraries Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Keywords: documentation Severity: minor Priority: P3 Component: driver AssignedTo: unassig...@gcc.gnu.org ReportedBy: rgue...@gcc.gnu.org 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.