Home › COBOL Tutorial › COBOL installation
COBOL installation
Full step-by-step installation for Windows, macOS and Linux.
Windows (through WSL)
- Open PowerShell as administrator and run
wsl --install. - Restart the computer, open Ubuntu from the Start menu and create a user name and password.
- Then follow the Linux steps below inside Ubuntu.
macOS (Homebrew)
- Install Homebrew from
brew.shif needed. - Run
brew install gnucobol.
Linux (Ubuntu or Debian)
- Run
sudo apt update. - Run
sudo apt install gnucobol.
Check the installation
- Open a new terminal.
- Run
cobc --version. A version number means it works.
Run your first program
- Save the code from the editor below as
hello.cob. Code lines start in column 8. - Compile with
cobc -x hello.cob. For free-format code usecobc -x -free hello.cob. - Run it with
./hello.
If something goes wrong
cobc: command not found: the install did not finish, or the terminal needs to be reopened.- Warning line not terminated by a newline: press Enter after the last line and save again.
Example code
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
PROCEDURE DIVISION.
DISPLAY "COBOL is installed".
STOP RUN.