User's Guide

Syntax
-Wl,-a,{archive|shared|shared_archive|archive_shared|default}
where,
-Wl,-a,archive Selects archive libraries. If the archive library does not exist,
the linker generates a warning message and does not create the
output file.
-Wl,-a,archive_shared If archive_shared is active, the archive form is preferred,
but the shared form is allowed.
-Wl,-a,shared Selects shared libraries. If shared libraries do not exist, the
linker generates a warning message and does not create the
output file.
-Wl,-a,shared_archive If shared_archive is active, the shared form is preferred, but
the archive form is allowed.
-Wl,-a,default Selects the shared library. If the shared library does not exist,
the linker selects the archive library.
Example
The following example directs the linker to use the archive version of the library libshape, followed
by standard shared libraries if they exist; otherwise select archive versions.
aCC box.o sphere.o -Wl,-a,archive -lshape -Wl,-a,default
Updating a Shared Library
The aCC command cannot replace or delete object modules in a shared library. To update a C++
shared library, you must recreate the library with all the object files you want the library to include.
For example, when a module in an existing shared library requires a fix, recompile the fixed
module with the +z or +Z option, and recreate the shared library with the -b option.
Programs that use this library will now use the new versions of the routines. You do not have to
relink programs that use this shared library because they are attached at run time.
Advanced Shared Library Features
This section explains additional things you can perform with shared libraries. It discusses the
following topics:
Forcing the Export of Symbols in main
Binding Times
Side Effects of C++ Shared Libraries
Routines and Options to Manage C++ Shared Libraries
Version Control for Shared Libraries
Adding New Versions to a Shared Library
Forcing the Export of Symbols in main
By default, the linker exports from a program only those symbols that were imported by a shared
library. For example, if shared libraries of an executable does not reference the main routine of
the program, the linker does not include the main symbol in the export list of a.out.
Normally, this is a problem only when a program explicitly calls shared library management
routines. (See “Routines and Options to Manage C++ Shared Libraries” (page 183).)
To make the linker export all symbols from a program, use the -Wl,-E option, which passes the
-E option to the linker.
182 Tools and Libraries