Kenwood HP 9000 Personal Computer User Manual


 
Chapter 5 145
Creating and Using Libraries
Creating Shared Libraries
Prior to the HP-UX 9.0 release, moving a shared library caused any
programs that were linked with the library to fail when they tried to load
the library. Prior to 9.0, you were required to relink all applications that
used the library if the library was moved to a different directory.
Beginning with the HP-UX 9.0 release, a program can search a list of
directories at run time for any required libraries. Thus, libraries can be
moved after an application has been linked with them. To search for
libraries at run time, a program must know which directories to search.
There are two ways to specify this directory search information:
Store a directory path list in the program with the linker option +b
path_list.
Link the program with +s, enabling the program to use the path list
defined by the SHLIB_PATH environment variable at run time.
For 64-bit programs, you can also use the LD_LIBRARY_PATH
environment variable, and the +s option is enabled by default.
For details on the use of these options, refer to “Moving Libraries after
Linking with +b” on page 84 and “Moving Libraries After Linking with
+s and SHLIB_PATH” on page 86.
Improving Shared Library Performance
This section describes methods you can use to improve the run-time
performance of shared libraries. If, after using the methods described
here, you are still not satisfied with the performance of your program
with shared libraries, try linking with archive libraries instead to see if it
improves performance. In general, though, archive libraries will not
provide great performance improvements over shared libraries.
Using Profile-Based Optimization on Shared Libraries
You can perform profile-based optimization on your shared libraries to
improve their performance. See “Profile-Based Optimization” on page
274 for more information.
Exporting Only the Required Symbols
Normally, all global variables and procedure definitions are exported
from a shared library. In other words, any procedure or variable defined
in a shared library is made visible to any code that uses this library. In
addition, the compilers generate “internal” symbols that are exported.