A library is a collection of grouped objects that are shared with another process or processes. There are three types of libraries: server libraries, client libraries, and connection libraries. Unless otherwise specified, statements in this section about libraries apply to all types of libraries.
Server Libraries and Export Objects
A server library is said to export objects. Exporting objects enables other processes to use objects that were declared by the server library process. A process that creates a server library is referred to as a server library process.
Client Libraries and Import Objects
A client library is said to import objects. Importing objects enables the client library process to use objects that were declared by another process. A process that creates a client library is referred to as a client process.
Library Objects
Server libraries are usually used in combination with client libraries. The objects exported by a server library, in turn, are imported for use by a client library process. Objects that are exported by one library and imported by another are referred to as library objects.
Connection Libraries
Connection libraries enable a two-way exchange of objects between processes. When two connection library processes establish a connection, each library can export objects for use by the other library. Both library processes can execute in parallel. Compared to server libraries, connection libraries also provide greater ability to monitor and control linkages with other processes.
Server, Client, and Connection Library Combinations
It is possible for server library programs to export objects to connection libraries. It is also possible for client programs to import objects from connection libraries. However, this section describes library capabilities mostly in terms of unmixed usage: server libraries that are used with client programs, and connection libraries that are used with other connection libraries. The combinations involving mixed usage are discussed under Other Library Linkage Methods later in this section.
Language Support
You can write server library programs in ALGOL, C, COBOL74, COBOL85, FORTRAN77, NEWP, and Pascal. You can write client programs in all of these languages, as well as in RPG. A library written in one language can be used by programs written in other languages.
You can write connection library programs only in ALGOL and NEWP.
Importing Process
This section makes some statements that apply both to client processes and to connection library processes that import objects. Because both these types of processes use imported objects, such a process is referred to by the term importing process in this section.
Procedure Objects
A procedure is the type of object most commonly exported by libraries. By consolidating procedures into a library, you can avoid duplicating the procedures in all the programs that need to use them. Further, you can maintain and enhance the shared procedures more easily when they reside in a library, because you do not have to repeat your work in every program that uses the procedures.
Data Objects
In addition to their role in providing shared procedures, libraries can also provide data structures to client processes. Thus,
-
ALGOL libraries can export simple types of variables, events, event arrays, and other types of arrays.
-
NEWP libraries can export events, event arrays, and other types of arrays.
-
FORTRAN77 libraries can export files and arrays.
-
Libraries in most other languages can provide client processes with indirect access to data objects that are declared in a library but not actually exported. The use of libraries to allow client processes to share data objects is discussed in Global Objects in Server Libraries and Global Objects in Connection Libraries later in this section.
Libraries Compared to Binding
Aside from libraries, the system provides several other methods by which programs can make use of a shared procedure, including binding, installation intrinsics, and separate programs. Compared to binding, libraries offer the following advantages:
-
Libraries export objects at run time, whereas the Binder adds procedures from one object code file to another for permanent storage. You have to run the Binder separately for each object code file to which a procedure is to be added. You have to run the Binder again for each of these object code files whenever you make changes to the shared procedure.
-
Libraries allow procedures to be shared between programs in a wider variety of languages than the Binder permits.
Libraries Compared to Installation Intrinsics
Compared to installation intrinsics, libraries offer the following advantages:
-
Libraries can include objects that are declared globally to the exported procedures. These could include files, databases, and so on.
-
Libraries can contain initialization and termination code.
-
Individual users can create their own libraries without possessing special privileges.
-
Libraries can be written in more languages than can installation intrinsics.
-
More than one version of a library can be in use at a time.
Libraries Compared to Separate Programs
Another method for sharing procedures is to write each procedure as a separate program. Any other program that needs to make use of one of these procedures can initiate the appropriate program as a task. Compared to this method of sharing procedures, libraries offer the following advantages:
-
The shared procedures can either be entered or initiated by the client program, whereas a separate program can only be initiated. Procedure entry takes less time and system resource than process initiation.
-
There are more programming languages that provide the ability to use libraries than there are programming languages that provide the ability to initiate programs.
COBOL74 Restrictions
This section notes various restrictions on COBOL74 libraries that arise because this language does not permit nested blocks. Note that COBOL85 does permit nested blocks, and consequently provides more complete access to library features than COBOL74.

