ld Manual

Introduction to ld
ld Manual529650.001
1-19
Searching for Archives and Libraries
Searching for Archives and Libraries
Default Search Locations
By default, ld searches a standard set of library locations for archive files, then for
libraries specified with the option -l or -lib.
You can stop ld from searching the standard library locations with the option -nostdlib
or -no_stdlib. ld also does not search the standard library locations for archive files
and libraries specified with qualified names on the ld command line.
Each version of ld searches a particular set of standard library locations by default:
In the Guardian execution environment, ld searches for libraries and archive files
in the subvolume with the current version of the operating system image (the active
$SYSTEM.SYSnn subvolume).
In the OSS execution environment, ld searches for libraries and archive files in
standard library locations, in the order shown:
1. The /lib directory.
2. The /usr/lib directory.
3. The /usr/local/lib directory.
In the OSS environment, the value of the COMP_ROOT environment variable is
added to the beginning of /lib, /usr/lib, and /user/local/lib. By default,
the value of COMP_ROOT is null.
Library Search Controls
The flags -bdynamic and -bstatic and -bdllsonly specify how ld will search for libraries
and archives, superseding the default behavior. Each flag can be specified multiple
times in the ld command stream. Once specified, these flags remain in effect until
another library search control option is specified.
If the -bdynamic flag is specified, ld first searches for a library. If a library cannot be
found, ld searches for an archive file. If neither file is found, ld issues an error
message. ld follows this process in each location (a subvolume or directory) it is
searching before moving on to the next location.
Example 1-10. Linking a Mixed-Language Program With IEEE Floating-Point
Format
ld $system.system.ccppmain cobj ptalobj -obey &
$system.system.licbobey -set floattype ieee_float -o myexec
Note. This subsection does not apply to the PC. On the PC, you must specify the location for
ld to look for libraries and archives. You cannot use standard library locations.