GnuCOBOL Setup & Execution Guide

This guide provides the necessary steps to install, configure, and run COBOL programs on a Windows environment using the GnuCOBOL compiler.


1. Installation

You can download the GnuCOBOL compiler from either of these sources:

  • Official SourceForge (Standard): Download GnuCOBOL
  • Arnold Trembley's Build (Recommended for Windows): Download .7z Installer
  • Note: If using the Arnold Trembley link, you must rename the file extension from .7z to .exe before running the installer.

Extract or install the contents to a path without spaces, for example: C:\GnuCOBOL.


2. System Environment Variables

To ensure the compiler can find its configuration files and binary tools, set the following variables in your System Environment Variables.

Primary Variables

Variable NameValue
COB_MAIN_DIRC:\GnuCOBOL
COB_CONFIG_DIRC:\GnuCOBOL\config
COB_COPY_DIRC:\GnuCOBOL\copy
COB_INCLUDE_DIRC:\GnuCOBOL\include
COB_LIB_DIRC:\GnuCOBOL\lib

Path Variable

Add the following to your Path variable:

  • C:\GnuCOBOL\bin

3. VSCode Configuration

To get syntax highlighting and code completion in VSCode, install the following extensions:

  • COBOL by bitlang
  • COBOL Extension Pack

4. Compiling and Running

To compile a COBOL program, use the cobc command in your terminal:

cobc -x -free hello.cob -o hello.exe
  • -x: Build an executable program.
  • -free: Use free-format COBOL (if applicable).
  • -o: Specify the output file name.

Run the compiled executable:

./hello.exe

You're all set! You can now write, compile, and execute COBOL programs on your Windows machine.