Using GnuCOBOL on Windows

GnuCOBOL (formerly OpenCOBOL) is a free implementation of the COBOL programming language. GnuCOBOL is a transcompiler to C which uses a native C compiler. Originally designed by Keisuke Nishida, the lead development was taken up by Roger While. The most recent developments are now led by Simon Sobisch, Ron Norman, Edward Hart, Sergey Kashyrin and many others.

Table of Contents

Background

I wrote this document to complement my video Installing GNUCobol on Windows which you can find on the Cobol Ninja YouTube channel. 

If you are new to Cobol, you can start off with the Hello Cobol World video, which goes into the bare basics needed to develop your first Cobol program.

The Hello Cobol World program

Our goal is not to just install, but to become Cobol programmers. So after installing all that we need, to get started, we will edit, compile and run the following program, which will display “Hello Cobol World!”

				
					       IDENTIFICATION DIVISION.
       PROGRAM-ID. CLS01EX01.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       PROCEDURE DIVISION.
           DISPLAY 'HELLO COBOL WORLD!'.
           STOP RUN.
           
				
			

Step 1- Installing GnuCobol

To download the GnuCOBOL compiler, we need to go to Arnold Trembley’s GnuCOBOL Downloads page, and scroll down to the stable 64-bit version for Windows, as seen here

After downloading, we have 2 things to do:

1. Create a new folder c:\gnuCobol for the GnuCOBOL compiler

2. Extract the GnuCOBOL compiler into c:\gnuCobol

The c:\gnuCobol folder after download and extracting into the folder

Step 2 - Installing Visual Studio Code

To download Visual Studio Code, we will go to the we need to go to Visual Studio Code download page as seen here, and download the 64-bit User installer for Windows 

Accept all defaults and follow the installation process. At the end, let it launch Visual Studio Code.

Initial launch of Visual Studio Code

To complete our preparations for using GnuCOBOL on Windows, we need to do the following:

1. Point VSCode to the GnuCOBOL folder

  • In the top menu, click on File
  • Click on Open Folder
  • Click on the new folder c:\gnuCobol
  • Click on the Select Folder button

The VS Code editor should display the new folder c:\gnuCobol on the left side, as seen here

 

2. Add the CLS01EX01.cob source file

  • If you hover on the line where the GNUCOBOL folder appears in the VSCode explorer, you will notice icons to the right. The first is for creating a new file in the folder.
  • When you click on the New File icon, a field will open in the folder, prompting for the new file name.
  • Type CLS01EX01.cob and click outside the field.
  • In the GNUCOBOL folder you will notice the new file CLS01EX01.cob that we just created.

The c:\gnuCobol folder after download and extracting into the folder

When you click on the file name, the edit pane for this source file will open in VS Code.

VSCode after clicking on new file CLS01EX01.con

 

3. Add VSCode Cobol extensions

We’re going to add two extensions that were made to support Cobol development in VSCode. This will allow the editor to alert us for syntax errors and more – for example, if we reference a variable which is not defined in the program. There are many different extensions, for now I would start out with these two.

  • On the left menu, click on the Extensions icon

Notice the Extensions icon on the lower left


  • In the Search field above, type “cobol”, and click on the first extension


  • In the Search field above, type “cobol”, and click on the first extension

Please leave your name and email and we’ll contact you

IMONIT Contact Form POSTS

Related Articles

Get in Touch

IMONIT Contact Form POSTS