nld Manual

nld Utility
nld Manual528272-001
2-20
Linking Archive Files
Linking Archive Files
The nld utility supports archive files for selecting input object files when building a new
object file. An archive file is created by the ar utility and contains a collection of object
files. Any type of file can be put into an archive, but nld uses only the relinkable
TNS/R native object files in an archive file.
To create an archive file, use the ar utility in either the Guardian environment, the OSS
environment, or on platforms running Windows. The nld utility supports archive files
existing in the Guardian and OSS environments, regardless of where the archives
were created. The ar utility is described in the noft Manual.
In the OSS environment, archive files often have filenames that start with lib and end
with the filename suffix .a, such as libc.a.
You can specify archive files on the nld command line directly and with the options -l
or -lib on page 3-7. Specifying archive files with options is usually easier than
specifying archive files on the command line.
nld resolves references using archive files in the order they are specified, either on
the command line directly or with -l or -lib options.
nld searches an archive file to resolve references. When nld finds object files that
satisfy references, it copies them from the archive file to the target object file. Unlike
Binder, nld copies the entire object file, not only the individual procedure.
For example, given object files obja, objb, and objc and archive files arc1 and
arc2 and this nld command line:
nld obja objb -lib arc1 objc arc2 -o myexec
nld performs these steps:
1. Copies obja and objb.
2. Searches arc1 for unresolved references in obja and objb. For those references
satisfied in arc1, nld copies the object file satisfying the reference.
3. Copies objc.
4. Searches arc2 for unresolved references in obja, objb, and objc. nld also
searches arc2 for unresolved references in object files copied from arc1.
A duplicate reference in an object file or an archive file generates an error.