Compiling COBOL code

Before you can run a program, you have to compile the source code.

You can configure the compilation using the following techniques:

The Compiler records errors with severity levels ranging from information messages to fatal errors which stop the Compiler working.

If the source code to be compiled contains characters beyond the standard 7-bit ASCII character set (for example, accented characters or characters belonging to multi-byte character sets), you must ensure that the locale has been set correctly, to match the source encoding of these characters. On UNIX, this means setting LANG, LC_CTYPE, or LC_ALL appropriately; each of these variables takes precedence over the former.

When you compile, the Compiler can produce executable code directly or object code. Object code is not executable, and has to be linked to the run-time system to create an executable file. If your project is set to build to .int and .gnt, by default the Compiler produces .int code during its syntax checking phase, and then it can produce .gnt code during the generating phase. You can modify this behavior from the project or the file properties.

Compiling from the command line

Using the command line, you can compile and link your program in one step using the cob command.

You can either specify all the information required on the command line, or use the Compiler prompts.

See Command line reference for more information.