Compiling Programs

Use the cob command to compile and link your sources.

The Compiler creates the intermediate code in a file with extension .int and produces extra information needed by Animator in an .idy file.

To compile your sources to JVM byte code (.class files), use the cob command with the -j flag: cob -j.

Using Compiler Directives

You can use Compiler directives to control the way in which your source code is compiled such as to change the syntax allowed by the Compiler and the output it produces. You can set the directives at the command line, in the source code or in a directives file.

For example, here's how you specify Compiler directives at the command line:

cob tictac.cbl osvs flag(osvs) list()

You are compiling your COBOL program with three directives. The first two describe the language you want to test for: the OSVS directive means you want the OSVS reserved word list used, and the FLAG(OSVS) directive means you want any syntax that is not OSVS-compatible to be indicated.

The final directive, LIST, means you want the source listing that the Compiler produces sent to a file. The parentheses mean you want to use the default name, which is your program name with an extension of .lst, so this creates tictac.lst.

Generating Callable Shared Objects

You can create a callable shared object file with the extension .so; this contains native machine code, which executes faster than intermediate code. Unlike .int and .gnt files, however, callable shared objects can contain more than one COBOL program and can also contain programs written in other language such as C and C++. Callable shared objects can also be linked with third-party object files or shared libraries. This behavior is similar to system executables and shared libraries but differs from .int files and .gnt files, where each file corresponds to a single COBOL program.

Generating Native Code

You can compile your program to create a file with extension .gnt containing native machine code, which executes faster than intermediate code.