Using CPLINK

The CPLINK command has the following syntax:
Read syntax diagramSkip visual syntax diagram
>>-CPLINK--OBJ--(--+------------------+--)---------------------->
                   |    .-+---+--.    |      
                   |    | '-,-'  |    |      
                   |    V        |    |      
                   '-'----object-+--'-'      

>--+-----------------------------------+------------------------>
   '-POPT--(--+-------------------+--)-'   
              |    .-+---+---.    |        
              |    | '-,-'   |    |        
              |    V         |    |        
              '-'----options-+--'-'        

>--+-----------------------------------+------------------------>
   '-PLIB--(--+-------------------+--)-'   
              |    .-+---+---.    |        
              |    | '-,-'   |    |        
              |    V         |    |        
              '-'----libname-+--'-'        

>--+-----------------------------------+------------------------>
   '-LOPT--(--+-------------------+--)-'   
              |    .-+---+---.    |        
              |    | '-,-'   |    |        
              |    V         |    |        
              '-'----options-+--'-'        

>--+----------------------------------+------------------------->
   '-LIB--(--+-------------------+--)-'   
             |    .-+---+---.    |        
             |    | '-,-'   |    |        
             |    V         |    |        
             '-'----libname-+--'-'        

>--+----------------------------------+------------------------><
   '-LOAD--(--+------------------+--)-'   
              |    .-+---+--.    |        
              |    | '-,-'  |    |        
              |    V        |    |        
              '-'----object-+--'-'        

OBJ
specifies an input data set name.

This is a required parameter. Each input data set must be a C object module compiled with the RENT or LONGNAME compiler options, or a compiled program (C or otherwise) having no static external data.

POPT
specifies a string of prelink options.
The prelinker options available for CPLINK are the same as for z/OS® batch. For example, if you want the prelinker to use the MAP option, specify the following:
CPLINK file name POPT('MAP')..

When you specify the prelink MAP option (as opposed to the link MAP option), the prelinker produces a file that shows the mapping of static external data. This map shows name, length, and address information. If there are any unresolved references or duplicate symbols during the prelink step, the map displays them.

PLIB
specifies the library names that the prelinker uses for the automatic library call facility.
LOPT
specifies a string of linkage editor options.
For example, if you want the prelink utility to use the MAP option, and the linkage editor to use the NOMAP option, use the following CLIST command:
CPLINK file name POPT('MAP') LOPT('NOMAP...')
LIB
specifies any additional library or libraries that the TSO LINK command uses to resolve external references. These libraries are appended to the default C library functions.
LOAD
specifies an output data set name.

If you do not specify an output data set name, a name is generated for you. The name that the CLIST generates consists of your user prefix, followed by CPOBJ.LOAD(TEMPNAME). For more information on the file format for output data, refer to z/OS MVS Program Management: User's Guide and Reference.

Examples

In the following example, your user prefix is RYAN, and the data set that contains the input object module is the partitioned data set RYAN.C.OBJ(INCCOMM). This example will generate a prelink listing without using the automatic call library. After the call, the load module is placed in the partitioned data set RYAN.CPOBJ.LOAD(TEMPNAME), and the prelink listing is placed in the sequential data set RYAN.CPOBJ.RMAP.
CPLINK OBJ('C.OBJ(INCCOMM)')

In the following examples, assume that your user prefix is PAUL, and the data set that contains the input object module is the partitioned data set PAUL.C.OBJ(INCPYRL). This example will not generate a prelink listing, and the automatic call facility will use the library RAINBOW.LIB.SUB. The load module is placed in the partitioned data set PAUL.TBD.LOAD(MOD).

Figure 1. Example of prelinking under z/OS batch
//*-----------------------------------------------------------
//* Prelink and link 'PAUL.C.OBJ(INCPYRL)'
//*-----------------------------------------------------------
//P0014001  EXEC EDCPL,
//          INFILE='PAUL.C.OBJ(INCPYRL)',
//          OUTFILE='PAUL.TBD.LOAD(MOD),DISP=SHR',
//          PPARM='NOMAP,NONCAL',
//          LPARM='AMODE(31),RMODE(ANY) '
//*----------------------------------------------------------
Figure 2. Example of prelinking under TSO
CPLINK OBJ('''PAUL.C.OBJ(INCPYRL)''')
      POPT('NOMAP,NONCAL')
      PLIB('''RAINBOW.LIB.SUB''')
      LOAD('TBD.LOAD(MOD)')