Install GnuCOBOL.

Version GnuCOBOL 3.2.0

Install Build-Essential first

In Terminal, Run:

sudo apt install build-essential

This might be installed already or there might be some components that are missing. Better safe then sorry.

Get GnuCOBOL

Download the source code from GnuCOBOL

As of May 2025, the current version is 3.2

For that version, download: gnucobol-3.2.tar.lz.

If you haven’t made any changes, it will be downloaded to the Downloads directory.

Extract the downloaded file

Open Files and go to the Downloads folder.

Double click on the gnucobol-3.2.tar.lz file.

This will open Archive Manager.

You will see “gnucobol-3.2”. Click on the “Extract” button in the upper left hand corner.

A dialog box will open to select where to extract the file to. Extract the file to the ~/builds directory.

When it is done, close the dialog box, close Archive Manager, and close Files.

Install additional software

Open Terminal to install the following:

sudo apt install libgmp-dev
sudo apt install libdb5.3-dev
sudo apt install libncurses-dev
sudo apt install libxml2-dev
sudo apt install libcjson-dev

Configure, Make and Install

Run:

cd
cd builds/gnucobol-3.2

This will take you into the gnucobol-3.2 directory.

Run:

./configure

A whole bunch of messages will print on the screen

At the end, there should be some messages that look like:

Dynamic loading: System
configure: Use gettext for international messages: yes
configure: Use fcntl for file locking: yes
configure: Use math multiple precision library: gmp
configure: Use curses library for screen I/O: ncursesw
configure: Use Berkeley DB for INDEXED I/O: yes
configure: Used for XML I/O: libxml2
configure: Used for JSON I/O: cjson

If there are no errors, Run:

make

More messages will display, if there are no errors, Run:

make check

A suite of tests will run, at the end, you should see the results:

# -------------
## Test results.
## -------------

1273 tests behaved as expected.
9 tests were skipped.

Run:

sudo make install

Then Run:

sudo ldconfig

Testing the Installation

Quick test

As a quick test, Run:

cobc

You should get an error message:

cobc: error: no input files

Better test

For a better test of the install:

  • Create a new directory
  • Create a simple COBOL program
  • Run it.

Create a new directory

In Terminal, Run:

cd
mkdir -p ~/dev/cobol/test-cobol
cd ~/dev/cobol/test-cobol
touch hello.cbl

Create a simple COBOL program

Open Files, go to the dev/cobol/test-cobol folder.

Double-click on hello.cbl. This will open it in Text Editor.

Copy the following code and paste it into hello.cbl:

   IDENTIFICATION DIVISION.
   PROGRAM-ID. SmallestProgram.
   DATA DIVISION.
   FILE SECTION.
   WORKING-STORAGE SECTION.
   PROCEDURE DIVISION.
   MAIN-PROCEDURE.
        DISPLAY "Hello world"
        STOP RUN.
   END PROGRAM SmallestProgram.

and save it.

Run it.

Go to Terminal, Run:

pwd

To make sure you are in the ~/dev/cobol/test-cobol directory.

Run:

cobc -x hello.cbl

If it complies correctly(no messages), Run:

./hello

It should return:

Hello world

If this works, delete the test-cobol directory (or not, your choice).