ambiguity of ld manual regarding to -L option!!

Tim Prince n8tm@aol.com
Sat Nov 20 15:26:00 GMT 2010


On 11/20/2010 12:31 AM, ali hagigat wrote:
> -L searchdir
> --library-path=searchdir
> The paths can also be specified in a link script with the SEARCH_DIR command.
> Directories specified this way are searched at the point in which the
> linker script
> appears in the command line.
> -----------------------------------------------------------------------------------------------
> I have copied part of ld manual...
> Can anyone give an example of how to specify a path for -L by a link script?
> When we use -L , we add some paths for search of ld command to find
> libraries and link scripts. But what does 'search at the point' mean?
> When 'searchdir' is specified by a link script, those paths should be
> considered for the whole session of ld, so why the position of link
> script is important? and if it is important how those paths are
> considered?
I guess you mean the gnu binutils ld manual.  This isn't really about 
gcc, gcc typically uses whatever linker is usual for the platform.  I 
think the "point" which is being made is that gnu ld searches .a 
("archive") libraries only in the order in which they are specified on 
the command line (by -lyourlibrary), so that dependencies which come up 
later won't be resolved.  Thus, it is usual to see all -l directives 
follow all source and .o file references.  For re-scanning a group of .a 
files which contain circular dependencies, you pass the option from gcc 
by -Wl,--start-group  first.a .... last.a -Wl,--end-group
You really should begin by looking at working examples for your 
platform.  A common error is in thinking that gnu ld, or even utilities 
based on it with the name "link," might behave the same as MSVC link or 
Solaris ld.

-- 
Tim Prince



More information about the Gcc-help mailing list