cob Command Examples

cob -x pi.cbl
Compiles the program in pi.cbl into a file called pi.int suitable for animation. As this is the default case, the -a flag does not need to be specified. Then links the COBOL source file pi.cbl to the run-time support libraries to form a system executable file named pi.
cob -i pi.cbl
Compiles the COBOL source file pi.cbl for the unlinked environment to produce an intermediate code file, pi.int
cob -u pi.cbl
Syntax-checks and generates the program in pi.cbl into a dynamically loadable .gnt file.
cob -z pi.cbl
Syntax-checks and generates the program in pi.cbl into a dynamically loadable callable shared object file.
cob -xo newrts routines.c
Builds an executable run-time system that contains C routines.
cob -z myprog routines.c
Syntax-checks, generates and links a callable shared object file that contains C routines
cob -xve "" -o my_rts -C xopen prog.cbl prog2.c
  • Compiles the COBOL source file prog.cbl and the C source file prog2.c
  • Compiles using the XOPEN Compiler directive
  • Links the result into a system executable file named my_rts that, when run, expects the name of the program to run to be given on its own command line
  • Gives verbose notification of progress
cob -x prog.cbl -d subprog
Builds a system executable file that has the main program prog linked and dynamically loads the subprogram subprog at run time.
cob -z subprog.cbl
Creates a dynamically loadable file for subprog as high performance machine. code. At run time, the program prog can be run by invoking the system executable file, as follows:
prog

The dynamic loader loads the subprogram when it is called. If the subprogram cannot be found and loaded, then if an ON EXCEPTION clause for the CALL exists it is executed, otherwise the run-time system gives an error.

Note: To run a system executable file by just giving its filename on the command line, the file must be held in a directory that appears in your PATH environment variable. Alternatively you can specify the full pathname, which for the above example would be . /prog .
cob -xe "" prog1.cbl prog2.cbl -o runprog

Builds an executable RTS that contains two programs such that the program to be run is selected at run time. The cob option -e "" specifies that the entry point, or the main program is given at run time and the -o option specifies the name of the system executable file as runprog.

To run the first program, enter the command:

runprog prog1

To run the second program, enter the command:

runprog prog2
cob -C "SOURCEFOMAT(FREE) ANIM" prog1.cbl
Compiles prog1.cbl into a file called prog1.int using the SOURCEFORMAT and ANIM Compiler directives.