ldinterface to system linker |
Command |
|
ld
[
-a
]
[
-b
]
[
-g
]
[
-l
library]
[
-L
directory]
[
-o
output_file]
[
-s
]
[
-T
value]
[
-Wphase,arg
]
files...
The
ld
command serves as an interface to the system linker
(
link
).
The
ld
command is invoked by the
cc
command to create executables or
shared libraries from object files and static libraries. While it is possible
to directly use
ld
, in most circumstances, it is preferable
to simply use
cc
and let that command
invoke the linker.
-a
- select the archive or static library (
libfoo.a
).
-b
- create a shared library (
libfoo.sl
).
-g
- keep debug information from object files.
-L
directory
- adds the directory to the beginning of the list of directories that the
linker searches for libraries. Any directories supplied on the command
line are searched first, in the order in which they appear on the command
line.
-l
library
- adds the specified library to the list of libraries to be searched. In
searching for libraries (for example, with
-lfoo
), each
library directory is first searched for the UNIX-style shared name
libfoo.sl
in each library directory; then, or if the
-a
option is specified, for the archive name
libfoo.a
in each library directory.
-o
output
- specifies the name of the output file.
-s
- strips debugging information from the output file.
-T
value
- specify a stack size.
-Wphase,arg
- passes arg to the specified compile phase.
l to the link indirect file
L to the link editor command line
- file.o
- file.a
- file.sl
- adds the object or library file to the list of files to be linked.
- CCG
- identifies the configuration file for the desired linker. If
CCG contains -, the the default configuration is read from
the standard input. If CCG contains a file name,
ld
uses that file as its default configuration file.
If CCG contains a directory name, ld
looks for the default configuration in the ld.ccg file in that
directory.
Possible exit status values are:
- 0
- Successful completion.
- >0
- An error occurred.
The ld utility, like many of the other compiler-related commands such as cc,
actually launches an appropriate CCG script (see the cc(5)) miscellaneous
reference page) to preprocess the options described before calling Link to
perform the actual linking. The actual CCG script run is determined by the
setting of the CCG environment variable (see ENVIRONMENT VARIABLES).
To modify
ld
(for example, to work with a different
linker), you simply need to modify the CCG script that
ld
runs based on the setting of the CCG environment
variable.
- Commands:
ar,
cc,
make,
strip