Installing gnuCOBOL into MinGW

I’ve been away from this project for several months and managed to forget exactly how I was supposed to invoke the COBOL compiler. I had made a note in the post
Installing gnuCOBOL on Windows, but that just tells where to find the compiler, not how to incorporate it into minGW.

I decided to incorporate gnuCOBOL into minGW again and document it for future use.

Download the Compiler

You can find the latest MinGW version at Arnold Trembley’s website. I want the version:

(NEW) GnuCOBOL 3.1-rc1 (30JUN2020) MinGW compiler for Windows XP/7/8/10 with COBOL ReportWriter. Includes VBISAM 2.0.1 for Indexed Sequential file access support, GMP 6.2.0, and PDCurses 4.1.99 (17.0 megabytes). Rename .7z to .exe for self-extracting archive.

If this website goes away, the above file (which will go out of date quickly) can also be found here.

Install the Compiler

I assume you have already installed MinGW. My notes on doing so can be found here.

Arnold Trembley’s version of gnuCOBOL is configured to reside at c:\mingw\share. Therefore, create the directory c:\mingw\share, and unzip the contects of the gnuCOBOL zip file into it.

Add C:\MinGW\share\gnucobol\bin to your path.

This almost is done. There is one problem yet: the path will be setup to run GCC out of /mingw/bin and that will cause a problem (mingw’s gcc compiler will be unable to find <libcobol.h>. You need to run it out of /mingw/share/gnucobol/bin.

To do this you must edit /etc/profile and insert /mingw/share/gnucobol/bin as shown:

# My decision to add a . to the PATH and as the first item in the path list
# is to mimick the Win32 method of finding executables.
# I filter the PATH value setting in order to get ready for self hosting the
# MSYS runtime and wanting different paths searched first for files.
if [ $MSYSTEM == MINGW32 ]; then
export PATH=".:/mingw/share/gnucobol/bin:/usr/local/bin:/mingw/bin:/bin:$PATH"
export PATH=".:/usr/local/bin:/bin:/mingw/bin:$PATH"

To Test

Start minGW bash and type cobc -v

chiefdude10/~:cobc -v cobc (GnuCOBOL) 3.1-rc1.0
Built Jul 04 2020 17:17:54 Packaged Jul 01 2020 00:39:30 UTC
C version (MinGW) "6.3.0"
loading standard configuration file 'default.conf'
cobc: error: no input files

You should see the bold line above, indicating that the default configuration is loaded.

The same will work in CMD:

C:\>cobc -v
cobc (GnuCOBOL) 3.1-rc1.0
Built Jul 04 2020 17:17:54 Packaged Jul 01 2020 00:39:30 UTC
C version (MinGW) "6.3.0"
loading standard configuration file 'default.conf'
cobc: error: no input files


You now have a working gnuCOBOL compiler!

To test, I created the following file (there are 7 spaces before ‘>>SOURCE FREE’):

       >>SOURCE FREE
*> Sample COBOL program
PROGRAM-ID. hello.
DISPLAY "Hello, world!".

To compile and run:

C:\cobol\helloworld>cobc -x helloW.cob

Hello, world!


This entry was posted in c-gnuCOBOL and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.