How do I compile a COBOL program on Windows?
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:
- Download the source code of the compiler for Windows from the official website and compile it yourself
- Install an IDE dedicated to COBOL, which directly integrates the compiler, such as OpenCobolIDE
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.cobfor 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.exein 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!
Complete courses, exercises and certificates to really learn programming!
4.8 average rating
No comments yet