64 Chapter 3
Linker Tasks
Using Linker commands
-a archive Select archive libraries. If the archive
library does not exist, ld generates
an error message and does not
generate the output file.
-a shared Select shared libraries. If the shared
library does not exist, ld generates
an error message and does not
generate the output file.
-a default This is the same as -a
shared_archive.
-a archive_shared Select the archive library if it exists;
otherwise, select the shared library. If
the library cannot be found in either
version, ld generates an error
message and does not generate the
output file.
-a shared_archive Select the shared library if it exists;
otherwise, select the archive library.
If the library cannot be found in
either version, ld generates an error
message and does not generate the
output file.
The -a shared and -a archive options specify only one type of library
to use. An error results if that type is not found. The other three options
specify a preferred type of library and an alternate type of library if the
preferred type is not found.
CAUTION You should avoid mixing shared libraries and archive libraries in the
same application. For more information see “Caution When Mixing
Shared and Archive Libraries” on page 164.
Example Using -a
The following command links with the archive versions of libcurses,
libm and libc:
$ ld /opt/langtools/lib/crt0.o prog.o -a archive -lcurses -lm -lc