7 Shared Library Management Routines

You can explicitly load and use shared libraries from your program. The linker toolset provides two families of load routines, dlopen and shl_load. The dlopen routines (primarily for IPF/PA-64 mode ) use Unix SVR4 compatible mechanism for library management. The shl_load routines support the shared library mechanisms provided in previous versions of HP-UX.

NOTE: Support for shl_load library management routines may be discontinued in a future IPF/PA-64 HP-UX release. You are encouraged to migrate to the dlopen family of routines for shared library management if you use the IPF/PA-64 mode linker toolset.

Do not mix use of the shl_load and dlopen APIs.

Shared Library Management Routine Summaries

The following sections introduce the shared library management routines.

The dlopen Routines Summary

The dlopen family of shared library management routines is available for the IPF and PA-64 linker. The following routines are also supported by the PA-32 linker:

dlopen

dlclose

dlsym

dlerror

dladdr

The dlopen family of routines use Unix SVR4 shared library mechanisms.

Use the following dl* routines for shared library management:

Table 22 dl* routines for shared library management

Routine

Action

“The dlopen Shared Library Management Routines”

Loads a shared library. This routine does breadth-first

(page 148)

searching.

 

 

“Description” (page 150)

Extension of dlopen allowing specific placement of text.

 

 

“The dlsetlibpath Routine” (page 153)

Sets the dynamic search path to locate shared libraries.

 

 

“The dlerrno Routine” (page 155)

Returns numeric error code corresponding to last error that

 

occurred during dynamic linking processing.

 

 

“The dlgetfileinfo Routine” (page 155)

Returns file information for a library prior to loading it.

 

 

“The dlerror Routine” (page 157)

Prints the last error message recorded by dld.

 

 

“The dlsym Routine” (page 157)

Gets the address of a symbol in a shared library.

 

 

“The dlget Routine” (page 159)

Returns information on a loaded module.

 

 

“The dlmodinfo Routine” (page 160)

Returns information about a loaded module.

 

 

“The dlgetname Routine” (page 161)

Retrieves the name of a loaded module, given a load model

 

descriptor.

 

 

“The dlclose Routine” (page 162)

Unloads a shared library previously loaded by dlopen().

 

 

“The dladdr Routine” (page 163)

Gets the symbolic information for an address.

 

 

“The dlmodadd Routine” (page 165)

Registers information about dynamically generated functions.

 

 

136 Shared Library Management Routines