is a date, specified with a compiler directive in the source file. The syntax of the version number directive depends on the language:

C and C++:

#pragma HP_SHLIB_VERSION "date"

FORTRAN:

$SHLIB_VERSION 'date'

Pascal:

$SHLIB_VERSION 'date'$

The date argument in all three directives is of the form month/year. The month must be 1 through 12, corresponding to January through December. The year can be specified as either the last two digits of the year (94 for 1994) or a full year specification (1994). Two-digit year codes from 00 through 40 represent the years 2000 through 2040. This directive must be used only if incompatible changes are made to a source file. If a version number directive is not present in a source file, the version number of all symbols defined in the object module defaults to 1/90.

Shared Library Dependencies and Version Control

A shared library as a whole can be thought of as having a version number itself. This version number is the most recent of the versioned symbols in the library and any dependent libraries.

When a shared library is built with a dependent shared library, the version number of the dependent library used during the link is recorded with the dependency.

When shl_load(3X) is called to load a shared library, the latest version of the library is loaded. If that library has dependencies, the dynamic loader (dld.sl(5)) loads the versions of the dependent libraries that were recorded in the dependency list. Note that these are not necessarily the most recent versions of the dependent libraries. When dld.sl loads a particular version of a shared library, it loads the same version of any dependent libraries.

If a shared library lists a second shared library as a dependency, dld.sl generates an error if the second shared library has a version number which is older than the version number recorded with the dependency. This means that the first library was built using a more recent version of the second library than the version that dld.sl currently finds.

Adding New Versions to a Shared Library

To rebuild a shared library with new versions of object files, run ld again with the newly compiled object files. For example, suppose you want to add new functionality to the routines in length.c, making them incompatible with existing programs that call libunits.sl. Before making the changes, make a copy of the existing length.c and name it oldlength.c. Then change the routines in length.c with the version directive specifying the current month and date. The following shows the new length.c file:

#pragma HP_SHLIB_VERSION "11/93" /* date is November 1993 */ /*

*New version of "in_to_cm" also returns a character string

*"cmstr" with the converted value in ASCII form.

*/

float in_to_cm(float in, char *cmstr) /* convert in to cm */

{

. . .

/*

build "cmstr" */

return(in * 2.54);

}

 

 

. . .

/*

other length conversion routines */

To update libunits.sl to include the new length.c routines, copy the old version of length.o to oldlength.o. Then compile length.c and rebuild the library with the new length.o and oldlength.o:

$ cp

length.c

oldlength.c

Save the

old source.

$ mv

length.o

oldlength.o

Save

old

length.o.

 

. . .

Make

new

length.c.

114 Creating and Using Libraries

Page 114
Image 114
HP UX Software Transition Kit (STK) manual Shared Library Dependencies and Version Control, #pragma Hpshlibversion date