How do I compile a COBOL program on Windows?

NicolasBrondinBernard

Author
@NicolasBrondinBernard

If you're just starting out with COBOL, OpenCobolIDE is one of the easiest ways to write, compile, and run your first program on Windows, without complex configuration.

Article published on 13/10/2025, last updated on 10/08/2026

One might think that compiling and running a COBOL program on Windows is quite an ordeal, but not at all.

You should know that the flagship compiler GnuCOBOL works perfectly on Windows!

However, two options are available to you:

It's this second method that we'll look at together in this article.

Installing OpenCobolIDE

To get started, simply download and install OpenCobolIDE from the official website.

This software includes everything you need:

  • a code editor,
  • the GnuCOBOL compiler,
  • and a built-in terminal to run the binary.

Once installed, you should be able to launch it and access the editor as shown in the following screenshot.

Creating your first program

To write your program, simply click on File → New → COBOL Source File, then copy and paste the following code:

       IDENTIFICATION DIVISION.
       PROGRAM-ID. HelloWorld.
       PROCEDURE DIVISION.
           DISPLAY "Hello, COBOL!"
           STOP RUN.

Then save your file under the name HelloWorld.cob for example.

Watch out, if your editor shows you errors, it's probably because you need to enable "Free format" mode at the bottom right of the window!

Compiling the program

To compile, you have two options:

Automatic compilation in the IDE

Simply click on Run (▶) — the program will be compiled and run directly in the built-in console.

Manual compilation

You can also open a Windows terminal and run the following command:

cobc -x HelloWorld.cob

This creates an executable named HelloWorld.exe in your current directory.

Then all that's left is to run the binary, like this:

HelloWorld.exe

Warning: Windows doesn't always correctly add the compiler's path to the PATH, you may need to do it manually!

You will find the compiler's path in OpenCobolIDE's Preferences by clicking on Edit > Preferences > Compiler

Result

Once you've run your program, here's what you should see appear in the console:

Hello, COBOL!

Congratulations, you've compiled your first COBOL program on Windows!

Bonus: Adding environment variables

It can sometimes be useful to work with environment variables in your program, so if you use the Run (▶) function built into the IDE, you'll find in the preferences the option to inject environment variables at program runtime, like this:

Now, it's your turn to try it out!


Finished reading this article?
Our complete courses
Take it to the next level with our courses!

Complete courses, exercises and certificates to really learn programming!

4.8 average rating

Comments (0)

to leave a comment

No comments yet

Frequently asked questions covered in this article

How to install OpenCobolIDE on Windows? How to run Cobol on Windows 11? How to install GnuCOBOL on Windows? How to run a COBOL program on Windows? How to add environment variables on OpenCobolIDE?