sudo apt update
sudo apt install gnucobol
Verify:
cobc --version
(You’ll get GnuCOBOL 3.1.2 – perfectly usable)
Save this as hello.cbl:
identification division.
program-id. hello.
procedure division.
display "Hello from GnuCOBOL!".
stop run.
Free format (recommended):
cobc -x -free hello.cbl
./hello
One-liner version:
cobc -x -free hello.cbl && ./hello
Build from source (latest stable 3.2):
sudo apt install build-essential autoconf automake libtool bison flex libgmp-dev libdb-dev libncurses-dev libltdl-dev
wget https://sourceforge.net/projects/gnucobol/files/gnucobol/3.2/gnucobol-3.2.tar.xz
tar xf gnucobol-3.2.tar.xz
cd gnucobol-3.2
./configure
make -j$(nproc)
sudo make install
After install → use /usr/local/bin/cobc