Following are the commands you can use to create a shared library called libunits.so:
$ cc
$ ld
Other topics relevant to shared libraries are:
•“Shared Library Dependencies” (page 100)
•“Updating a Shared Library” (page 102)
•“Shared Library Location (IPF)” (page 102)
•“Improving Shared Library Performance” (page 102)
•“Function Level Versioning” (page 110)
Creating
In
•Compile source files with the +z or +Z compiler option, described below.
•Write assembly language programs that use appropriate addressing modes, described in “Writing and Generating
In
Example Using +z
Suppose you have some C functions, stored in length.c, that convert between English and Metric length units. To compile these routines and create PIC object files with the C compiler, you can use this command:
$ cc | The +z option creates PIC. |
You can then link it with other PIC object files to create a shared library, as discussed in “Creating the Shared Library with ld” (page 99) .
Comparing +z and +Z
In
In
Compiler Support for +z and +Z
In
In
Creating the Shared Library with ld
To create a shared library from one or more PIC object files, use the linker, ld, with the
For example, suppose you have three C source files containing routines to do length, volume, and mass unit conversions. They are named length.c, volume.c, and mass.c, respectively. To make a shared library from these source files, first compile all three files, then combine the resulting
.o files with ld. Following are the commands you can use to create a shared library named libunits.so:
Creating Shared Libraries 99