Kenwood HP 9000 Personal Computer User Manual


 
138 Chapter 5
Creating and Using Libraries
Creating Shared Libraries
Creating Shared Libraries
Two steps are required to create a shared library:
1. “Creating Position-Independent Code (PIC)” by compiling with +z.
2. “Creating the Shared Library with ld” by linking with -b.
Shown below are the commands you would use to create a shared library
called libunits.sl:
$ cc -Aa -c +z length.c volume.c mass.c
$ ld -b -o libunits.sl length.o volume.o mass.o
Other topics relevant to shared libraries are:
“Shared Library Dependencies”
“Updating a Shared Library”
“Version Control with Shared Libraries”
“Shared Library Location”
“Improving Shared Library Performance”
Creating Position-Independent Code (PIC)
The first step in creating a shared library is to create object files
containing position-independent code (PIC). There are two ways to
create PIC object files:
Compile source files with the +z or +Z compiler option, described
below.
Write assembly language programs that use appropriate addressing
modes, described in Chapter 7, “Position-Independent Code,” on page
259.
In 32-bit mode, the +z and +Z options force the compiler to generate PIC
object files. In 64-bit mode, the +Z option is the default.