Specifying Libraries with
To direct the linker to search a particular library, use the
Specifying Libraries
When writing programs that call routines not found in the default libraries linked at compile time, you must specify the libraries on the compiler command line with the
The x argument corresponds to the identifying portion of the library path name - the part following lib and preceding the suffix .a or .sl. For example, for the libm.sl or libm.a library, x is the letter m:
$ cc
The linker searches libraries in the order in which they are specified on the command line (that is, the link order). In addition, libraries specified with
Using the
The
The advantage of using this option is that it allows you to specify an archive or shared library explicitly without having to change the state of the
For instance, suppose you use the LDOPTS environment variable (see “Passing Linker Options with LDOPTS” (page 44) ) to set the
Example Using
For example, even if LDOPTS were set to
$ ld /opt/langtools/lib/hpux32/crt0.o
Flagging Unsatisfied Symbols with +[no]allowunsats
Use the +allowunsats option to instruct the linker to not flag unsatisfied symbols at link time. This is the default for relocatable
Use the +noallowunsat option to instruct the linker to flag as an error any unsatisfied symbol in the resulting output file. The linker still creates a.out, but the file does not have any execute permission bits set. This is the default for program files (same behavior as in
For example, where main() references functions foo() and bar(). The bar() resides in libbar and foo() resides in libfoo
$ ld main.o +allowunsats
ld: (warning) Unsatisfied symbol "foo". 1 warning.
Using Linker Commands 45