HP-UX Linker and Libraries User's Guide

Using Shared Libraries with cc and ld Options.........................................................................138
Initializers for Shared Libraries................................................................................................138
Styles of Initializers ..........................................................................................................138
Init/Fini Style Initializers...............................................................................................138
HP-UX-10.X Style Initializers...........................................................................................139
Using Init/Fini Initializers..................................................................................................139
Init and Fini Usage Example.........................................................................................139
Ordering Within an Executable or Shared Library...........................................................141
Ordering Among Executables and Shared Libraries.........................................................142
Using HP-UX 10.X Style Initializers......................................................................................143
Declaring the Initializer with the +I Option......................................................................143
Order of Execution of Multiple Initializers.......................................................................143
Initializer Syntax..........................................................................................................144
Accessing Initializers' Addresses...............................................................................144
Example: An Initializer for Each Library..........................................................................144
Example: A Common Initializer for Multiple Libraries........................................................146
The dlopen Shared Library Management Routines.....................................................................148
The dlopen Routine .........................................................................................................148
Syntax ......................................................................................................................148
Return Values..............................................................................................................149
Description.................................................................................................................150
Using dlopen to load a shared library...........................................................................152
The dlsetlibpath Routine....................................................................................................153
Synopsis....................................................................................................................153
Description.................................................................................................................153
Using dlsetlibpath to set the dynamic search path.......................................................154
Multithread Usage.......................................................................................................155
Return Value...............................................................................................................155
Errors........................................................................................................................155
The dlerrno Routine..........................................................................................................155
Synopsis....................................................................................................................155
Description.................................................................................................................155
The dlgetfileinfo Routine....................................................................................................155
Synopsis....................................................................................................................155
Description.................................................................................................................155
Multithread Usage.......................................................................................................157
Return Value...............................................................................................................157
Errors........................................................................................................................157
The dlerror Routine...........................................................................................................157
Syntax.......................................................................................................................157
Description.................................................................................................................157
Using dlerror to get diagnostic information.....................................................................157
The dlsym Routine............................................................................................................157
Syntax.......................................................................................................................157
Return Values..............................................................................................................158
Description.................................................................................................................158
Usage.......................................................................................................................158
Using dlopen and dlsym to access either function or data objects......................................158
The dlget Routine.............................................................................................................159
Syntax.......................................................................................................................159
Return Values..............................................................................................................159
Description.................................................................................................................159
Using dlget to retrieve information about loaded modules.................................................160
The dlmodinfo Routine......................................................................................................160
Syntax ......................................................................................................................160
8 Contents