To invoke the Cob utility, enter the following from a UNIX system command prompt:
cob-command [options|filename] ...
Your effective working mode is determined by the COBMODE environment variable, global settings or, if none of these is set, the default (64-bit). To show the effective working mode, enter cobmode at the command line without any arguments.
The cob command assumes that any unrecognized options are either input files or valid linker options to be saved and used at link time. In this way, any archive files you supply to the cob command are passed to the linker, which pulls out only the referenced files from the archive.
The cob command needs to know the location of the COBOL system components, and so you need to ensure the following environment variables are set appropriately:
The cob command needs to know the location of the COBOL system components. They must all be located in a directory in which a COBOL system has been installed, as defined by the $COBDIR environment variable. The default $COBDIR directory is /usr/lpp/cobol on AIX, or /opt/lib/cobol otherwise.
If your COBOL system is not installed in the default location, you must set the COBDIR environment variable to point to the directory containing the system components. The pathname of the location must not exceed 51 characters.
You can install different versions of the COBOL system on your machine, in which case you select the one to use by setting its location in COBDIR. For example, the following specifies that the system components are located in the directory /home/products/cob10:
COBDIR=/home/products/cob10 export COBDIR
PATH=$COBDIR/bin:$PATH export PATH
Ensure that LIBPATH, SHLIB_PATH or LD_LIBRARY_PATH (depending on your operating system) is set to $COBDIR/lib.
cob -xve "" -o my_rts -C xopen prog.cbl prog2.c
The above command passes the XOPEN directive to the Compiler and instructs cob to compile the COBOL source file prog.cbl and the C source file prog2.c and to link 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. The cob utility also gives verbose notification of its progress.
The above command assumes that neither the file $COBDIR/etc/cobopt nor the COBOPT environment variable exist.