codegurukool.com · Free coding tutorials & online compiler

Home › COBOL Tutorial › COBOL installation

COBOL installation

Full step-by-step installation for Windows, macOS and Linux.

Windows (through WSL)

  1. Open PowerShell as administrator and run wsl --install.
  2. Restart the computer, open Ubuntu from the Start menu and create a user name and password.
  3. Then follow the Linux steps below inside Ubuntu.

macOS (Homebrew)

  1. Install Homebrew from brew.sh if needed.
  2. Run brew install gnucobol.

Linux (Ubuntu or Debian)

  1. Run sudo apt update.
  2. Run sudo apt install gnucobol.

Check the installation

  1. Open a new terminal.
  2. Run cobc --version. A version number means it works.

Run your first program

  1. Save the code from the editor below as hello.cob. Code lines start in column 8.
  2. Compile with cobc -x hello.cob. For free-format code use cobc -x -free hello.cob.
  3. Run it with ./hello.

If something goes wrong

Example code

       IDENTIFICATION DIVISION.
       PROGRAM-ID. HELLO.
       PROCEDURE DIVISION.
           DISPLAY "COBOL is installed".
           STOP RUN.

Run this code in the online editor

← COBOL introductionCOBOL get started →