Object Libraries

An object library is a file that contains one or more compiled ACUCOBOL-GT programs. Object libraries can simplify the distribution of an application by reducing the number of files involved. They can also help improve performance by reducing the number of directory operations performed by runcbl when it is loading object modules. The advantages are particularly noticeable if the number of object files in a directory is large.

Each object library contains a primary module. The primary module is the first (or only) module in the library. When the library is loaded by a CALL statement (or is the first program of a run unit), the primary module is the program that is loaded and run. Other modules in an object library can be loaded by subsequent CALL statements.

In order for the runtime system to access other object modules in a library, the primary module must be loaded. It may either be active or inactive, but it must be physically present in memory. A program is loaded whenever it is called; it is unloaded whenever it is canceled (or when it exits, if it has the INITIAL attribute). See Memory Management for a more complete description of runtime memory management.

Assuming that the primary module is loaded, then the other modules in the object library can be called if their name matches the name specified in a CALL verb. Modules in an object library are identified by PROGRAM-ID. If a matching name is found in an object library, that object module is then loaded and executed. See Calling Subprograms for more information.

As suggested by these rules, you should place related object files together. Usually this is done by specifying the main program of a run unit as the primary module and then adding in some or all of the subprograms it calls.

Object libraries may also be pre-loaded. This is done with the -y option of runcbl. When a library is pre-loaded, all of its modules are always available. Note that pre-loading does not mean that the component object modules and contained ENTRY points are physically loaded into memory. It just means that the directory of the contained modules is loaded. More than one library may be pre-loaded, and pre-loaded libraries may be used with dynamically loaded libraries with no restrictions.