Example: using cob2 to compile and link under z/OS UNIX
The following examples illustrate the use of cob2.
- To compile one file called alpha.cbl, enter:
cob2 -c alpha.cblThe compiled file is named alpha.o.
- To compile two files called alpha.cbl and beta.cbl, enter:
cob2 -c alpha.cbl beta.cblThe compiled files are named alpha.o and beta.o.
- To link two files, compile them without the
-coption. For example, to compile and link alpha.cbl and beta.cbl and generate gamma, enter:cob2 alpha.cbl beta.cbl -o gammaThis command creates alpha.o and beta.o, then links alpha.o, beta.o, and the COBOL libraries. If the link step is successful, it produces an executable program named gamma.
- To compile alpha.cbl with the
LISTandNOADATAoptions, enter:cob2 -qlist,noadata alpha.cbl - To compile alpha.cbl with the
SQLoption so that the database request module (DBRM) is written to member "alpha" of the existing PDS data setUSER.COBOL.DBRMLIB, enter:cob2 -qsql alpha.cbl -o alpha -dbrmlib=USER.COBOL.DBRMLIBNote: The SQL coprocessor must be in yourSTEPLIBin order for this to work. - To compile alpha.cbl with the
SQLoption so that the database request module (DBRM) is written to z/OS® UNIX filealpha.dbrm, enter:cob2 -qsql alpha.cbl -o alpha -dbrmlibNote: The SQL coprocessor must be in yourSTEPLIBin order for this to work, and you need to use the SQL coprocessor for Db2® 12 with APAR PI88171 applied.