cobc: the COBOL compiler

Compile modes

cobc compiles a .cob or .cbl file. The -x flag produces a runnable executable instead of a module, and -o names the output file:

cobc -x -o hello hello.cob

Useful flags

Two flags make learning easier. -free switches from fixed-format columns to free-format source, and -Wall asks for more warnings:

cobc -x -free -Wall -o hello hello.cob

Run and trace

The compiler can also build and run your program in one step with -j, which is handy while you experiment:

cobc -x -free -j hello.cob

Hello from COBOL

The code on this page was run with GnuCOBOL 3.2.0 on Alpine Linux 3.24.3 (x86_64) in a Docker container.

Article author: Arthur Isaev