Using LINK

The general form of the TSO LINK command is:

Read syntax diagramSkip visual syntax diagram
>>-LINK--+-data-set-name-----------+---------------------------->
         | .-,-------------------. |   
         | V                     | |   
         '---(--data set name--)-+-'   

>--+---------------------------+--LIB--------------------------->
   '-LOAD--(--data set name--)-'        

>--+-data-set-name-----------+---------------------------------><
   | .-,-------------------. |   
   | V                     | |   
   '---(--data-set-name--)-+-'   

Input to the LINK command

You must specify one or more object module names, or load module names, after the LINK keyword. For example, to link-edit program2.obj, using the Language Environment® Library, you would issue the following:
LINK program2.obj LIB('CEE.SCEELKED')
Note: You must always specify 'CEE.SCEELKED' in the LIB operand. It is not required during the execution of a z/OS® XL C/C++ program.

LIB operand of the LINK command

The LIB operand specifies the names of data sets that are to be used to resolve external references by the automatic library call facility. Language Environment Library is made available to your program in this manner and must always be specified on the LIB operand. In the following example, SALESLIB.LIB.SBRT2 is used to resolve external references used in program2.
LINK program2.obj LIB('CEE.SCEELKED.', 'SALESLIB.LIB.SBRT2')
A request coded this way searches CEE.SCEELKED and SALESLIB.LIB.SBRT2 to resolve external references.

LOAD operand of the LINK command

In the LOAD operand, you can specify the name of the data set that is to hold the load module as follows:
LINK LOAD(load-mod-name(member)) LIB('CEE.SCEELKED')

The load module produced by the linkage editor must be a member in a partitioned data set.

If you do not specify a data set name for the load module, the system constructs a name by using the first data set name that appears after the keyword LINK, and it will be placed in a member of the user-prefix.program-name.LOAD data set. If the input data set is sequential and you do not specify a member name, TEMPNAME is used.

Example: The following example shows how to link-edit two object modules and place the resulting load module in member TEMPNAME of the userid.LM.LOAD data set.

LINK program1,program2 LOAD(lm)

You can also specify link-edit options in the link statement:

LINK program1 LOAD(lm) LET

Options for the linkage editor are discussed in Output from the linkage editor.

For more information about using the TSO command LINK, see z/OS TSO/E Command Reference .

Specifying link-edit options through the TSO LINK command

TSO users specify link-edit options through the LINK command. For example, to use the MAP, LET, and NCAL options when the object module in SMITH.PROGRAM1.OBJ is placed in SMITH.PROGRAM1.LOAD(LM), enter:
LINK SMITH.PROGRAM1 'LOAD(LM) MAP LET NCAL'
You can use link-edit-options to display a map listing at your terminal:
LINK PROGRAM1 MAP PRINT(*)

Storing load modules in a load library

If you want to link C functions, to store them in a load library, and to INCLUDE them later with main procedures, use the NCAL and LET linkage editor options.