Referencing Libraries

To use a library, the calling program does the following:

  • Declares the library in a LIBRARY declaration, specifying the attributes of the library

  • Declares the entry points of the library in PROCEDURE declarations with library entry point specification parts

When an entry point is invoked or at an explicit linkage request, the operating system automatically creates the library linkage. If the library program has not already been initiated, the operating system initiates it; then, when the library is frozen, the operating system links the library to the calling program. The operating system attempts to make linkages to all entry points referenced in a library at the time that the library is first invoked.

The LINKLIBRARY function can be used to determine whether or not the calling program is currently linked to, or is capable of being linked to, a particular library program. If the calling program is not currently linked but is capable of being linked, the linkage is performed. During the linkage process, an attempt is made to link to every entry point exported from the library whose name matches an entry point declared in the calling program. Only those names that match are checked for correct function type, number of parameters, and parameter types. Therefore, the LINKLIBRARY function does not check that every entry point declared in the calling program is also exported from the library. For more information, see LINKLIBRARY Function.

The CANCEL statement and the DELINKLIBRARY function can be used to terminate the linkage between a calling program and a library. The CANCEL statement causes the library to unfreeze and resume running as a regular program regardless of whether it is temporary or permanent. Only PRIVATE libraries or SHAREDBYRUNUNIT libraries can be canceled. The DELINKLIBRARY function has no effect on any other users of the library. For more information, see DELINKLIBRARY Function.

The SETACTUALNAME function determines whether or not the name of a particular library entry point can be changed in the template to a particular character string and, if possible, makes the change. The name of an entry point of a linked library cannot be modified. Therefore, a linked library must be delinked before the SETACTUALNAME function can be called to change the name of any of its entry points. For more information, see SETACTUALNAME Function.