Linux Notes: GnuCOBOL on Linux

  1. The information presented here is intended for educational use by qualified computer technologists.
  2. The information presented here is provided free of charge, as-is, with no warranty of any kind.
back to: Linux Notes (index)
Edit: 2026-10-03

Introduction

Back in the days of mainframes and minicomputers, COBOL licenses were very expensive (eg. starting at tens of thousands of dollars per machine).

One neat thing about Linux and open source software is that a fairly good COBOL compiler called GnuCOBOL could be downloaded then installed for zero dollars.

The following instructions describe nothing new and are only meant to pique your curiosity.

Installing GnuCOBOL (on RHEL, CentOS, AlmaLinux, etc)

caveats:

command notes
yum list \*-release\* display all available distros
yum install epel-release
install yum support for the epel distro (required for gnucobol)
yum list \*cobol\*
display all available packages containing the string "cobol"
yum install gnucobol
install gnucobol
which cobc locate where was the binary stored
man cobc read the online manual
yum list vim\* display all available packages beginning with vim
yum install vim-enhanced install vim (the "vim" editor is superior to "vi" for most programming work)

online help: https://gnucobol.sourceforge.io/doc/gnucobol.html

A few very important compiler switches (of many)

Switch Notes
-m build a dynamically loadable module (default)
-x
build an executable program (overrides -m)
-ftext-column=132 increases the right side limit from 72 to 132
-free
removes left side limits for code and remarks
increases the right side limit from 72 to 511
note: all remarks must be modified from from "*" to "*>"
-help
display this help and exit
-V
display compiler version information and exit
-info display the compiler's build environment
-std=<dialect> cobol2014, cobol2002, cobol85, ibm, etc.
-t error.log save compiler output to the specified file 
-tlines=132 increase -t listing from 55
-T error.log save wide compiler output to the specified file 
--list-intrinsics display built-in functions (eg. INDEX-OF is probably missing)

hello-world

hello-world-classic.cob

Notes:

hello-world-free-format.cob

Notes:

indexed-file support via ISAM

a few words about ISAM

indexed-file-demo1.cob

Notes:

indexed-file-demo2.cob

Notes:

Index of local demo programs

File Demo Notes
hello-world-classic.cob 1
a classic COBOL demo
hello-world-free-format.cob 2
a free-format COBOL demo
index-file-demo1.cob 3
a classic COBOL ISAM demo with a problem (and solution)
index-file-demo2.cob 4 a multi-key ISAM demo converted from DEC-BASIC to COBOL (translation done via Google Gemini in 2026)
sql-demo1.cob 5 coming soon

Gotchas, FUBARs, and SNAFUs

Number 1 (DISPLAY WITH NO ADVANCING)

Number 2 (program compiles but will not run)

Links


Back to Home
Neil Rieck
Waterloo, Ontario, Canada.