HP aC++/HP C A.06.20 Programmer's Guide

NOTE: When you specify the -b option to create a shared library, these defaults do
not apply.
Linking with Shared or Archive Libraries
If you want archive libraries instead of shared libraries, use the -a, archive linker
option. To create a completely archived executable, use the +A option. To maintain
compatibility with future releases, do not mix archive and shared libraries should not
be mixed.
Refer to the HP-UX Linker and Libraries User’s Guide for more information.
Specifying Other Libraries
You can specify other libraries using the -l option. For example, to use the Tools.h++
library, specify -lrwtool:
aCC myapp.C -lrwtool
Creating and Using Shared Libraries
This section describes shared libraries that are specific to HP aC++. It discusses the
following topics:
Compiling for Shared Libraries
Creating a Shared Library
Using a Shared Library
Linking Archive or Shared Libraries
Updating a Shared Library
Compiling for Shared Libraries
To create a C++ shared library, you must first compile your C++ source with either the
+z or +Z option. These options create object files containing position-independent code
(PIC).
Example
The following example compiles util.C, generates position-independent code, and
puts the code into the object file util.o. util.This object file can later be put into a
shared library.
aCC -c +z util.C
Creating a Shared Library
To create a shared library from one or more object files, use the -b option at link time.
(The object files must have been compiled with +z or +Z.) The -b option creates a
shared library rather than an executable file.
234 Tools and Libraries