Chapter Contents |
Previous |
Next |
Linking C Programs |
Using Cataloged Procedures to Link |
Three
cataloged procedures are provided for
compiling and linking or simply linking a C program. LC370L and LC370CL should
be used to link programs that do not require the use of COOL (non-reentrant
programs that do not use
extname
, AR370 archives, or the all-resident library).
LC370L and LC370CL do not invoke COOL. LC370LR should be used to link programs
that require the use of COOL. This procedure runs COOL before invoking the
linkage editor.
Link-Editing without COOL |
If your program requires an entry point other
than the standard MAIN entry, the entry point must be explicitly specified.
See Specifying the Correct Entry Point for further information.
ENV=STD ENV=SPE
The default is ENV=STD, which specifies the standard OS/390 environment. ENV=SPE specifies a program that uses the minimal SPE environment. See Systems Programming with the SAS/C Compiler for more information about SPE.
The LC370L Cataloged Procedure |
Typical JCL for running the cataloged procedure LC370L to link-edit a procedure is shown in Sample JCL for Link-Editing with Procedure LC370L. Both the LC370L and the LC370CL cataloged procedure listings follow the sample JCL.
Sample JCL for Link-Editing with Procedure LC370L
//JOBNAME JOB job card information //*------------------------------------------------------------- //* LINK EDIT A C PROGRAM //*------------------------------------------------------------- //LINK EXEC LC370L,PARM.LKED='options' //*------------------------------------------------------------- //* REPLACE GENERIC NAMES AS APPROPRIATE //*------------------------------------------------------------- //LKED.SYSLMOD DD DISP=SHR,DSN=your.load.library(member) //LKED.SYSIN DD DSN=your.object.library(member),DISP=SHR //LKED.libname DD DSN=your.object.library ,DISP=SHR //
The LKED.libname DD statement is required if you use the linkage editor INCLUDE libname control statement. SYSIN can be a file of object code or control statements. (See the IBM OS/390 linkage editor and loader documentation for your particular installation.) Any linkage editor options can go in the PARM.LKED string. If no options are provided, LIST and MAP are assumed. The LC370L procedure contains the JCL shown in Expanded JCL for LC370L.
Expanded JCL for LC370L
//LC370L PROC ENTRY=MAIN,ENV=STD, // CALLLIB='SASC.BASELIB', // SYSLIB='SASC.BASELIB' //**************************************************************** //* NAME: LC370L (LC370L) *** //* PROCEDURE: LINKAGE *** //* DOCUMENTATION: SAS/C COMPILER AND LIBRARY USER'S GUIDE *** //* FROM: SAS INSTITUTE INC., SAS CAMPUS DRIVE, CARY, NC *** //**************************************************************** //* //* ************************************************************** //* ENV=STD: MODULE RUNS IN THE NORMAL C ENVIRONMENT //* ENV=SPE: MODULE USES THE SYSTEMS PROGRAMMING ENVIRONMENT //* ENTRY=MAIN: MODULE IS A NORMAL C MAIN PROGRAM //* ENTRY=DYN: MODULE IS DYNAMICALLY LOADABLE AND REENTRANT //* ENTRY=DYNNR: MODULE IS DYNAMICALLY LOADABLE AND NON-REENTRANT //* ENTRY=OS: MODULE IS AN OS SPE APPLICATION //* ENTRY=OE: MODULE IS AN USS SPE APPLICATION //* ENTRY=NONE: ENTRY POINT TO BE ASSIGNED BY USER //* ************************************************************** //LKED EXEC PGM=LINKEDIT,PARM='LIST,MAP',REGION=1536K //SYSPRINT DD SYSOUT=A,DCB=(RECFM=FBA,LRECL=121,BLKSIZE=1210) //SYSTERM DD SYSOUT=A //SYSLIN DD DSN=C.SASC.BASEOBJ(EP@&ENTRY), // DISP=SHR // DD DDNAME=SYSIN //SYSLIB DD DSN=C.SASC.&ENV.LIB, // DISP=SHR STDLIB OR SPELIB // DD DSN=&SYSLIB,DISP=SHR COMMON RESIDENT LIBRARY // DD DSN=&CALLLIB,DISP=SHR //SYSUT1 DD DSN=&&SYSUT1,UNIT=SYSDA,DCB=BLKSIZE=1024, // SPACE=(1024,(200,50)) //SYSLMOD DD DSN=&&LOADMOD(MAIN),DISP=(,PASS),UNIT=SYSDA, // SPACE=(1024,(50,20,1))
Note the following about this example:
The LC370CL Cataloged Procedure |
The LC370CL procedure can be used to compile and link-edit a program that does not require preprocessing by COOL. LC370CL contains the JCL shown in Expanded JCL for LC370CL. This JCL is correct as of the publication of this guide. However, it may be subject to change.
Expanded JCL for LC370CL
//LC370CL PROC ENTRY=MAIN,ENV=STD, // CALLLIB='SASC.BASELIB', // MACLIB='SASC.MACLIBC', // SYSLIB='SASC.BASELIB' //**************************************************************** //* NAME: LC370CL (LC370CL) *** //* SUPPORT: C COMPILER DIVISION *** //* PRODUCT: SAS/C *** //* PROCEDURE: COMPILATION AND LINKAGE *** //* DOCUMENTATION: SAS/C COMPILER AND LIBRARY USER'S GUIDE *** //* FROM: SAS INSTITUTE INC., SAS CAMPUS DRIVE, CARY, NC *** //**************************************************************** //* //* ****************************************************************** //* ENV=STD: MODULE RUNS IN THE NORMAL C ENVIRONMENT //* ENV=SPE: MODULE USES THE SYSTEMS PROGRAMMING ENVIRONMENT //* ENTRY=MAIN: MODULE IS A NORMAL C MAIN PROGRAM //* ENTRY=DYN: MODULE IS DYNAMICALLY LOADABLE AND REENTRANT //* ENTRY=DYNNR: MODULE IS DYNAMICALLY LOADABLE AND NON-REENTRANT //* ENTRY=OS: MODULE IS AN OS SPE APPLICATION //* ENTRY=OE: MODULE IS AN USS SPE APPLICATION //* ENTRY=NONE: ENTRY POINT TO BE ASSIGNED BY USER //* ****************************************************************** //C EXEC PGM=LC370B //STEPLIB DD DSN=SASC.LOAD, // DISP=SHR COMPILER LIBRARY // DD DSN=SASC.LINKLIB, // DISP=SHR RUNTIME LIBRARY //SYSTERM DD SYSOUT=* //SYSPRINT DD SYSOUT=* //SYSUT1 DD UNIT=SYSDA,SPACE=(TRK,(10,10)) //SYSUT2 DD UNIT=SYSDA,SPACE=(TRK,(10,10)) //SYSUT3 DD UNIT=SYSDA,SPACE=(TRK,(10,10)) //SYSLIN DD DSN=&&OBJECT,SPACE=(3200,(10,10)),DISP=(MOD,PASS), // UNIT=SYSDA,DCB=(RECFM=FB,LRECL=80) //SYSLIB DD DSN=&MACLIB,DISP=SHR STANDARD MACRO LIBRARY //SYSDBLIB DD DSN=&&DBGLIB,SPACE=(4080,(20,20,1)),DISP=(,PASS), // UNIT=SYSDA,DCB=(RECFM=U,BLKSIZE=4080) //SYSTMP01 DD UNIT=SYSDA,SPACE=(TRK,25) VS1 ONLY //SYSTMP02 DD UNIT=SYSDA,SPACE=(TRK,25) VS1 ONLY //* //LKED EXEC PGM=LINKEDIT,PARM='LIST,MAP',COND=(8,LT,C) //SYSPRINT DD SYSOUT=*,DCB=(RECFM=FBA,LRECL=121,BLKSIZE=1210) //SYSTERM DD SYSOUT=* //SYSLIN DD DSN=*.C.SYSLIN,DISP=(OLD,PASS),VOL=REF=*.C.SYSLIN // DD DSN=SASC.BASEOBJ(EP@&ENTRY), // DISP=SHR // DD DDNAME=SYSIN //SYSLIB DD DSN=SASC.&ENV.LIB, // DISP=SHR STDLIB OR SPELIB // DD DSN=&SYSLIB,DISP=SHR COMMON RESIDENT LIBRARY // DD DSN=&CALLLIB,DISP=SHR //SYSUT1 DD DSN=&&SYSUT1,UNIT=SYSDA,DCB=BLKSIZE=1024, // SPACE=(1024,(200,50)) //SYSLMOD DD DSN=&&LOADMOD(MAIN),DISP=(,PASS),UNIT=SYSDA, // SPACE=(1024,(50,20,1))
Note the following about this example:
Link-Editing with COOL |
The LC370LR Cataloged Procedure |
Typical JCL for running the cataloged procedure LC370LR to invoke COOL and link-edit a procedure is shown in Sample JCL for Executing COOL with Procedure LC370LR.
Sample JCL for Executing COOL with Procedure LC370LR
//JOBNAME JOB job card information //*------------------------------------------------------------- //* LINK EDIT A C PROGRAM WITH COOL //*------------------------------------------------------------- //LINK EXEC LC370LR,PARM.LKED='options' //*------------------------------------------------------------- //* REPLACE GENERIC NAMES AS APPROPRIATE //*------------------------------------------------------------- //LKED.SYSLMOD DD DISP=SHR,DSN=your.load.library(member) //LKED.SYSIN DD DSN=your.object.library(member) ,DISP=SHR //LKED.libname DD DSN=your.object.library ,DISP=SHR //LKED.SYSLDLIB DD DSN=your.autocall.load.library ,DISP=SHR //
LC370LR does not support the ENTRY symbolic parameter.
However, you need to supply an ENTRY statement when you use LC370LR only
if you require an unusual entry point, such as $MAINC, $MAINO, a function
compiled with the
indep
option, or a specialized SPE start-up routine. Dynamically loadable
modules and SPE modules that use a standard start-up routine should be linked
correctly by LC370LR without an explicit ENTRY specification.
Any linkage editor options can go in the PARM.LKED string. If no options are provided, LIST and MAP are assumed. In addition, COOL accepts the options listed in COOL Options.
The LC370LR procedure contains the JCL shown in Expanded JCL for LC370LR. This JCL is correct as of the publication of this guide. However, it may be subject to change. Note that LC370LR supports ENV=GOS for a program that uses GOS (generalized operating system interface).
Expanded JCL for LC370LR
//LC370LR PROC ENV=STD,ALLRES=NO, // CALLLIB='SASC.BASEOBJ', // SYSLIB='SASC.BASEOBJ' //**************************************************************** //* PRODUCT: SAS/C *** //* PROCEDURE: COOL LINKAGE EDITOR PREPROCESSOR & LINK EDIT *** //* DOCUMENTATION: SAS/C COMPILER AND LIBRARY USER'S GUIDE *** //* FROM: SAS INSTITUTE INC., SAS CAMPUS DRIVE, CARY, NC *** //**************************************************************** //* //* ENV=STD: MODULE RUNS IN THE NORMAL C ENVIRONMENT //* ENV=CICS: MODULE RUNS IN A CICS C ENVIRONMENT //* ENV=GOS: MODULE RUNS USING THE GENERALIZED OPERATING //* SYSTEM INTERFACE //* ENV=SPE: MODULE USES THE SYSTEMS PROGRAMMING ENVIRONMENT //* ****************************************************************** //LKED EXEC PGM=COOLB,PARM='LIST,MAP',REGION=1536K //STEPLIB DD DSN=SASC.LOAD, // DISP=SHR C COMPILER LIBRARY // DD DSN=SASC.LINKLIB // DISP=SHR C RUNTIME LIBRARY //SYSPRINT DD SYSOUT=A,DCB=(RECFM=FBA,LRECL=121,BLKSIZE=1210) //SYSTERM DD SYSOUT=A //SYSLIN DD UNIT=SYSDA,DSN=&&LKEDIN,SPACE=(3200,(20,20)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=3200) //SYSLIB DD DDNAME=AR#&ALLRES ARESOBJ OR ENVIRONMNENT OBJ FILE // DD DSN=SASC.&ENV.OBJ, // DISP=SHR ENVIRONMENT SPECIFIC OBJECT FILE // DD DSN=&SYSLIB,DISP=SHR COMMON RESIDENT LIBRARY // DD DSN=&CALLLIB,DISP=SHR //SYSUT1 DD DSN=&&SYSUT1,UNIT=SYSDA,DCB=BLKSIZE=1024, // SPACE=(1024,(200,50)) //SYSLMOD DD DSN=&&LOADMOD(MAIN),DISP=(,PASS),UNIT=SYSDA, // SPACE=(1024,(50,20,1)) //AR#NO DD DSN=SASC..&ENV.OBJ, // DISP=SHR //AR#YES DD DSN=SASC.ARESOBJ, // DISP=SHR
The LC370CLR Cataloged Procedure |
The LC370CLR procedure can be used to compile and link-edit a program, invoking the COOL linkage editor preprocessor during the linkage step. LC370CLR contains the JCL shown in Expanded JCL for LC370CLR. This JCL is correct as of the publication of this guide. However, it may be subject to change.
Expanded JCL for LC370CLR
//LC370CLR PROC ENV=STD,ALLRES=NO, // CALLLIB='SASC.BASEOBJ', // MACLIB='SASC.MACLIBC', // SYSLIB='SASC.BASEOBJ' //**************************************************************** //* NAME: LC370CLR (LC370CLR) *** //* PRODUCT: SAS/C *** //* PROCEDURE: COMPILATION, PRELINK (COOL) AND LINKAGE *** //* DOCUMENTATION: SAS/C COMPILER AND LIBRARY USER'S GUIDE *** //* FROM: SAS INSTITUTE INC., SAS CAMPUS DRIVE, CARY, NC *** //**************************************************************** //* //* ****************************************************************** //* ENV=STD: MODULE RUNS IN THE NORMAL C ENVIRONMENT //* ENV=GOS: MODULE RUNS USING THE GENERALIZED OPERATING //* SYSTEM INTERFACE //* ENV=SPE: MODULE USES THE SYSTEMS PROGRAMMING ENVIRONMENT //* ****************************************************************** //C EXEC PGM=LC370B //STEPLIB DD DSN=SASC.LOAD, // DISP=SHR COMPILER LIBRARY // DD DSN=SASC.LINKLIB, // DISP=SHR RUNTIME LIBRARY //SYSTERM DD SYSOUT=* //SYSPRINT DD SYSOUT=* //SYSUT1 DD UNIT=SYSDA,SPACE=(TRK,(10,10)) //SYSUT2 DD UNIT=SYSDA,SPACE=(TRK,(10,10)) //SYSUT3 DD UNIT=SYSDA,SPACE=(TRK,(10,10)) //SYSLIN DD DSN=&&OBJECT,SPACE=(3200,(10,10)),DISP=(MOD,PASS), // UNIT=SYSDA,DCB=(RECFM=FB,LRECL=80) //SYSLIB DD DSN=&MACLIB,DISP=SHR STANDARD MACRO LIBRARY //SYSDBLIB DD DSN=&&DBGLIB,SPACE=(4080,(20,20,1)),DISP=(,PASS), // UNIT=SYSDA,DCB=(RECFM=U,BLKSIZE=4080) //SYSTMP01 DD UNIT=SYSDA,SPACE=(TRK,25) VS1 ONLY //SYSTMP02 DD UNIT=SYSDA,SPACE=(TRK,25) VS1 ONLY //* //LKED EXEC PGM=COOLB,PARM='LIST,MAP',COND=(8,LT,C),REGION=1536K //STEPLIB DD DSN=SASC.LOAD, // DISP=SHR COMPILER LIBRARY // DD DSN=SASC.LINKLIB, // DISP=SHR RUNTIME LIBRARY //SYSPRINT DD SYSOUT=*,DCB=(RECFM=FBA,LRECL=121,BLKSIZE=1210) //SYSTERM DD SYSOUT=* //SYSLIN DD UNIT=SYSDA,DSN=&&LKEDIN,SPACE=(3200,(20,20)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=3200) //SYSLIB DD DDNAME=AR#&ALLRES ARESOBJ OR STDOBJ OR SPEOBJ // DD DSN=SASC.&ENV.OBJ, // DISP=SHR STDOBJ OR SPEOBJ // DD DSN=&SYSLIB,DISP=SHR COMMON RESIDENT LIBRARY // DD DSN=&CALLLIB,DISP=SHR //SYSUT1 DD DSN=&&SYSUT1,UNIT=SYSDA,DCB=BLKSIZE=1024, // SPACE=(1024,(200,50)) //SYSLMOD DD DSN=&&LOADMOD(MAIN),DISP=(,PASS),UNIT=SYSDA, // SPACE=(1024,(50,20,1)) //AR#NO DD DSN=SASC.&ENV.OBJ, // DISP=SHR //AR#YES DD DSN=SASC.ARESOBJ, // DISP=SHR //SYSIN DD DSN=*.C.SYSLIN,DISP=(OLD,PASS),VOL=REF=*.C.SYSLIN
Linking All-Resident Programs |
All-resident programs can be linked
with the cataloged procedures that invoke COOL, LC370LR, or LC370LRG. (Note
the
ALLRES=YES
symbolic parameter is available for both procedures.)
When linking an all-resident program, use the
ALLRES=YES
symbolic parameter, and include an object deck created by
compiling
a source file that includes
<resident.h>
and the appropriate macro definitions.
See All-Resident C Programs for more information.
For example, suppose a program consists of three object files, MAINPROG, SUB1, and SUB2. The program also includes object code from a PDS named MY.PROG.OBJLIB. The JCL to normally link this program is shown in Sample LC370LR JCL.
Sample LC370LR JCL
//JOBNAME JOB job card information //LINK EXEC LC370LR,PARM.LKED='options' //* //LKED.SYSLMOD DD DISP=SHR,DSN=MY.PROG.LOAD(TESTPROG) //LKED.SYSIN DD DSN=MY.PROG.OBJ(MAINPROG),DISP=SHR // DD DSN=MY.PROG.OBJ(SUB1),DISP=SHR // DD DSN=MY.PROG.OBJ(SUB2),DISP=SHR //LKED.OBJLIB DD DSN=MY.PROG.OBJLIB,DISP=SHR //
To create an all-resident version of the load module,
include the object file generated by compiling a C source file containing
<resident.h>
and the appropriate macro definitions, and add the
ALLRES=YES
JCL parameter,
as shown in Sample LC370LR JCL for Linking an All-Resident Program.
Sample LC370LR JCL for Linking an All-Resident Program
//JOBNAME JOB job card information //LINK EXEC LC370LR,PARM.LKED='options',ALLRES=YES //* //LKED.SYSLMOD DD DISP=SHR,DSN=MY.PROG.LOAD(TESTPROG) //LKED.SYSIN DD DSN=MY.PROG.OBJ(MAINPROG),DISP=SHR // DD DSN=MY.PROG.OBJ(SUB1),DISP=SHR // DD DSN=MY.PROG.OBJ(SUB2),DISP=SHR // DD DSN=MY.PROG.OBJ(RESLIST),DISP=SHR //LKED.OBJLIB DD DSN=MY.PROG.OBJLIB,DISP=SHR //
Note:
Alternately, to create an all-resident
version of the load module, you could add the
#include
and appropriate
#define
statements to an existing source file (for instance, MAINPROG) and
recompile that source file.
COOL and Linkage Editor JCL Requirements |
You need the DD statements shown in Data Sets Needed for Running COOL to invoke COOL.
You need the DD statements shown in Data Sets Needed for Running the Linkage Editor to invoke the linkage editor.
Sample JCL for Running COOL and the Linkage Editor shows sample JCL for running COOL and the linkage editor.
Sample JCL for Running COOL and the Linkage Editor
//JOBNAME JOB job card information //*------------------------------------------------------------- //* RUN THE COOL LINKAGE EDITOR PREPROCESSOR //*------------------------------------------------------------- //COOL EXEC PGM=COOL#,REGION=2048K //STEPLIB DD DISP=SHR,DSN=compiler.loadlib // DD DISP=SHR,DSN=sasc.transient.library //*------------------------------------------------------------ //* REPLACE GENERIC NAMES AS APPROPRIATE //*------------------------------------------------------------ //SYSIN DD DSN=c.primary.input ,DISP=SHR //SYSLIB DD DSN=sasc.baseobj ,DISP=SHR // DD DSN=sasc.stdobj ,DISP=SHR // DD DSN=c.user.subroutine.library,DISP=OLD //SYSLIN DD DSN=cool.output.object.dataset,DISP=SHR //libname DD DSN=user.defined.object,DISP=SHR //SYSPRINT DD SYSOUT=class //SYSTERM DD SYSOUT=class //*---------------------------------------------------------------- //* RUN LINKAGE EDITOR //*---------------------------------------------------------------- //LINK EXEC PGM=IEWL,PARM='LIST,MAP,XREF,LET',COND=(8,LE,COOL) //SYSUT1 DD UNIT=SYSDA,SPACE=(CYL,(1,1)) //SYSLIN DD DSN=cool.output.object.dataset,DISP=SHR //libname DD DSN=user.defined.library,DISP=SHR //SYSLIB DD DSN=your.autocall.library,DISP=SHR //SYSLMOD DD DISP=SHR,DSN=output.load.library(member) //SYSPRINT DD SYSOUT=class //
Linking USS Programs |
//LKED.SYSLMOD DD PATH='output-module-path', // PATHOPTS=(OWRONLY,OCREAT), // PATHMODE=(SIRWXU)
COOL Options (Short Forms) |
COOL takes short-form options, as summarized in COOL Options Equivalents. The options can be in upper- or lowercase. As with the short forms of the compiler and OMD options, you specify positive forms of the option with a hyphen (-) as the initial character; specify negative forms with an exclamation point (!) or not sign (¬). Refer to COOL Options for complete descriptions of these options.
The following is an example of an EXEC statement that invokes COOL with the option NOWARN:
// EXEC PGM=COOL#,PARM='!W'
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.