Chapter 3 57
Linker Tasks
Using Linker commands
Using Linker commands
This section describes linker commands for the 32-bit and 64-bit linker.
NOTE Unless otherwise noted, all examples show 32-bit behavior.
Linking with the 32-bit crt0.o Startup File
In 32-bit mode, you must always include crt0.o on the link line.
In 64-bit mode, you must include crt0.o on the link line for all fully
archive links (ld -noshared) and in compatibility mode (+compat). You
do not need to include the crt0.o startup file on the ld command line
for shared bound links. In 64-bit mode, the dynamic loader, dld.sl, does
some of the startup duties previously done by crt0.o.
See “The crt0.o Startup File” on page 43, and the crt0(3) man page for
more information.
Changing the Default Library Search Path
with -L and LPATH
You can change or override the default linker search path by using the
LPATH environment variable or the -L linker option.
Overriding the Default Linker Search Path with
LPATH
The LPATH environment variable allows you to specify which directories
ld should search. If LPATH is not set, ld searches the default directory
/usr/lib. If LPATH is set, ld searches only the directories specified in
LPATH; the default directories are not searched unless they are specified
in LPATH.
If set, LPATH should contain a list of colon-separated directory path
names ld should search. For example, to include /usr/local/lib in
the search path after the default directories, set LPATH as follows:
$ LPATH=/usr/lib:/usr/local/lib Korn and Bourne shell syntax.
$ export LPATH