-Ldir
Segher Boessenkool
segher@kernel.crashing.org
Mon Apr 25 06:29:00 GMT 2011
> Are the search paths for libraries the same as linker scripts exactly?
> Does the current directory is the first directory which is searched
> for libraries?
> When we use -Ldir, it adds a directory to search but where? after
> current directory and before system directories? or after system
> directories?
> Current directory is searched first for hear files?
> The manual does not explain search paths clearly in one section.
It does, but you want to read the linker manual instead of the GCC
manual.
If you use GNU LD, the manual says:
`-L SEARCHDIR'
`--library-path=SEARCHDIR'
Add path SEARCHDIR to the list of paths that `ld' will search for
archive libraries and `ld' control scripts. You may use this
option any number of times. The directories are searched in the
order in which they are specified on the command line.
Directories specified on the command line are searched before the
default directories. All `-L' options apply to all `-l' options,
regardless of the order in which the options appear. `-L' options
do not affect how `ld' searches for a linker script unless `-T'
option is specified.
If SEARCHDIR begins with `=', then the `=' will be replaced by the
"sysroot prefix", a path specified when the linker is configured.
The default set of paths searched (without being specified with
`-L') depends on which emulation mode `ld' is using, and in some
cases also on how it was configured. *Note Environment::.
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.
Segher
More information about the Gcc-help
mailing list