Writing JCL for the prelinker and linkage editor

You can use cataloged procedures rather than supply all of the job control language (JCL) required for a job step that invokes the prelinker or linkage editor. However, you should be familiar with these JCL statements. This familiarity enables you to make the best use of the prelinker and linkage editor and, if necessary, override the statements of the cataloged procedure.

For a description of the IBM-supplied cataloged procedures that include a prelink and link step, see Cataloged procedures and REXX EXECs.

The following sections describe the basic JCL statements for prelinking and linking.

Using the EXEC statement

Use the EXEC job control statement in your JCL to invoke the prelinker. The following example shows an EXEC statement that invokes the prelinker:

//PLKED EXEC PGM=EDCPRLK

You can also use the EXEC job control statement in your JCL to invoke the linkage editor. The following sample shows an EXEC statement that invokes the linkage editor:

//LKED EXEC PGM=HEWL
Note: If you are using DLLs, you must use the RENT linkage editor option.

Using the PARM parameter

By using the PARM parameter of the EXEC statement, you can select one or more of the optional facilities that the prelinker and linkage editor provide.

For example, if you want the prelinker to use the automatic call library to resolve unresolved references, specify the NONCAL prelinker option using the PARM parameter on the prelinker EXEC statement:
//PLKED EXEC PGM=EDCPRLK,PARM='NONCAL'
If you want a mapping of the load modules produced by the linkage editor, specify the MAP option with the PARM parameter on the linkage editor EXEC statement:
//LKED EXEC PGM=HEWL,PARM='MAP'

For a description of prelinker options see Prelinker options, for linkage editor options see Linkage editor options.

Example of JCL to prelink and link

Figure 1 shows a typical sequence of job control statements to link-edit an object module into a load module.

Figure 1. Creating a load module under z/OS batch
  //*-------------------------------------------------------------
  //* PRE-LINKEDIT STEP:
  //*-------------------------------------------------------------
  //PLKED  EXEC PGM=EDCPRLK,REGION=2048K,PARM='MAP'
  //STEPLIB  DD  DSN=CEE.SCEERUN,DISP=SHR
  //         DD  DSN=CEE.SCEERUN2,DISP=SHR
  //SYSMSGS  DD  DSN=CEE.SCEEMSGP(EDCPMSGE),DISP=SHR
  //SYSLIB   DD  DSN=CEE.SCEECPP,DISP=SHR
  //         DD  DSN=CBC.SCLBCPP,DISP=SHR
  //SYSIN    DD  DSN=USERID.TEXT(PROG1),DISP=SHR
  //SYSMOD   DD  DSN=&&PLKSET,UNIT=VIO,DISP=(MOD,PASS),
  //             SPACE=(32000,(30,30)),
  //             DCB=(RECFM=FB,LRECL=80,BLKSIZE=32000)
  //SYSDEFSD DD  DSN=USERID.TEXT(PROG1IMP),DISP=SHR
  //SYSOUT   DD  SYSOUT=*
  //SYSPRINT DD  SYSOUT=*
  //*-------------------------------------------------------------
  //* LINKEDIT STEP:
  //*-------------------------------------------------------------
  //LKED   EXEC PGM=HEWL,REGION=1024K,COND=(8,LE,PLKED),PARM='MAP'
  //SYSLIB   DD  DSN=CEE.SCEELKED,DISP=SHR
  //SYSLIN   DD  DSN=*.PLKED.SYSMOD,DISP=(OLD,DELETE)
  //SYSLMOD  DD  DSN=USERID.LOAD(PROG1),DISP=SHR
  //SYSUT1   DD  UNIT=VIO,SPACE=(32000,(30,30))
  //SYSPRINT DD  SYSOUT=*
Note: For a C++ application, this JCL uses static class libraries.

Specifying link-edit options through JCL

In your JCL for link-edit processing, use the PARM statement to specify link-edit options:
PARM=(link-edit-options)
PARM.STEPNAME=('link-edit-options') (If a PROC is used)
where link-edit-options is a list of link-edit options. Separate the link-edit options with commas.

You can prelink and link C/C++ applications under z/OS® batch by submitting your own JCL to the operating system or by using the IBM® cataloged procedures. See Cataloged procedures and REXX EXECs for more information on the supplied procedures.