COBOL Manual for TNS and TNS/R Programs
Issues Related to Binding and Linking
HP COBOL Manual for TNS and TNS/R Programs—522555-006
24-12
Binding or Linking Automatically
Putting an Object File on the Primary Search List
If a CALL or ENTER statement does not contain a mnemonic name that specifies the
object file that contains the called program, the compiler searches for the called routine
in the object files on the primary search list. If the COBOL85 compiler finds the routine,
it validates the routine’s actual parameters and includes the routine in your object file. If
the NMCOBOL compiler finds the routine, it validates the routine’s actual parameters
and includes the entire object file (from the primary search list) in the object file that it is
creating.
You can put one or more object files on the primary search list with one or more
SEARCH directives. The first SEARCH directive establishes the primary search list
and adds files to it in the specified order. Subsequent SEARCH directives append files
to the primary search list in the specified order. The compiler searches the object files
of the primary search list in order. If the compiler finds the routine, it stops searching for
it.
Suppose that the object code for most of the external routines that your TNS
HP COBOL program calls is in four different object libraries: CBLRTNS, an HP COBOL
object file; CRTNS, an HP C object file; FTNRTNS, a FORTRAN object file; and
PSCRTNS, a Pascal object file. Suppose that most of the external routines that your
program calls are in CBLRTNS, almost equal numbers are in FTNRTNS and CRTNS,
and very few are in PSCRTNS. For greatest efficiency, put CBLRTNS first on the
primary search list, then FTNRTNS and CRTNS (in either order), and finally
PSCRTNS. You can use the directive:
?SEARCH CBLRTNS,FTNRTNS,CRTNS,PSCRTNS
Alternatively, you can use multiple SEARCH directives, which can appear anywhere in
your HP COBOL program. This code produces the same primary search list as the
preceding directive:
?SEARCH CBLRTNS
?SEARCH FTNRTNS,CRTNS
?SEARCH PSCRTNS
If you put a SEARCH directive on the compilation command line when you compile
your program, the compiler sees that SEARCH directive first, so the primary search list
begins with that SEARCH directive’s object files.
Making an Object File the User Library
If the compiler does not find an external routine in any of the files on the primary
search list, it searches for the routine in the user library. A loadfile can have only one
user library.
If the compiler finds the routine in the user library, it validates the routine’s actual
parameters but does not include the routine in your object file. The system loader
resolves the routine at fixup. If the compiler finds the routine in the user library, it stops
searching for it.