COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
Topics:
• Linking Automatically (page 817)
• Linking Programs to Be Called Dynamically (page 818)
Linking Automatically
If you specify the RUNNABLE directive, the compiler automatically links the program, interacting
with the eld utility.
For simplicity, this explanation attributes actions of internal processes and the eld utility to the
compiler.
Unless all the external routines that your program calls are in the file ECOBEXT, ZCOBDLL, or
ZCREDLL, you must tell the compiler which object files contain the external routines that your
program calls. There are several ways to tell the compiler about a specific object file:
• Establish a mnemonic name for the object file and use it in CALL or ENTER statements.
• Put the object file’s name on the primary search list.
If the compiler finds an external routine in an object file on the primary search list, it validates
the routine’s parameters and includes the entire object file in your program’s object file.
• Put the object file’s name on the tertiary search list.
If the compiler finds an external routine in an object file on the tertiary search list, it validates
the routine’s actual parameters but does not include the routine in your program’s object file.
The system loader resolves the routine at fixup.
You can use a predefined DEFINE, =_OBJECT_SEARCH, to specify one or more subvolumes for
the compiler to search for unqualified object files (see Specifying Subvolumes to Be Searched for
Unqualified Files (page 756)).
Topics:
• Establishing a Mnemonic Name for an Object File (page 817)
• Putting an Object File on the Primary Search List (page 818)
• Putting an Object File on the Tertiary Search List (page 818)
Establishing a Mnemonic Name for an Object File
If a CALL or ENTER statement contains a mnemonic name that specifies the object file that contains
the called program, the compiler searches that file (and only that file) for the specified routine. If
the compiler does not find the routine, it reports an error.
You establish a mnemonic name for an object file with a File-Mnemonic clause in the
SPECIAL-NAMES paragraph of the Environment Division. Suppose that the object file has the system
file name MYLIB and you want to give it the mnemonic name HERLIB. The File-Mnemonic clause
is:
FILE "MYLIB" IS HERLIB.
Suppose that MYLIB contains a COBOL program named APROG. Your HP COBOL program can
call APROG with the statement:
CALL "APROG" OF HERLIB.
Quotation marks around the program name (APROG) are not required, but are recommended. If,
in some eventual program maintenance, someone adds a variable named APROG to a program
that already calls a program named APROG, and the name APROG is not in quotation marks, the
compiler assumes that APROG refers to the variable. At run time, if the variable APROG does not
contain the name of a valid program that is included in the object file, the program terminates with
the error message “Called program not found.” If APROG is enclosed in quotes, the compiler
recognizes it as a program name rather than a variable.
Linking HP COBOL Programs 817










