Installing MinGW (for gnuCOBOL)

As I started researching how to install the gnuCOBOL SQL preprocessor, I found that there are no binaries (Windows or Linux). If I’m going to move forward, I’m going to have to be able to  compile the preprocessor.

One option is to take a step backwards and redo what I’ve done so far on Linux. But for no particularly good reason, I want to do this project on Windows. That means getting gcc running under Windows. Cue minGW.

For what seems like 20 years, I’ve been using unxutils to provide Unix based commands in Windows which allows me to move between Windows and Linux seamlessly. BUT unxutils just provides some basic utilities, it doesn’t provide the ability to compile and run C programs on Windows.

One option is the new Windows Subsystem for Linux (WSL). I have multiple issues with this – it requires Windows 10 64bit, is a full blown Linux install, and it is Microsoft. I’m looking for simple, small, and clean. That is not typical of Microsoft. OK, I have an attitude.

The other options are MinGW or cygwin. gnuCOBOL for Windows is compiled on MinGW and the preprocessor seems to have no preference, so I will install MinGW and see how it goes.

The plus side to MinGW is it will replace my old unxutils and provide the same features plus provide bash on top of Windows.

MinGW Installation

Considering the general complexity of what is being installed, the installation is amazingly simple. You download an installer which works much like the Linux Synaptic Manager. From there you select which parts of MinGW you want to install.

The installer is found at https://sourceforge.net/projects/mingw/files/Installer/

Once started, I selected the default options (installing into c:\MinGW). Once the installer is setup, it asks which parts of MinGW you want to install. I selected mingw32-base (gcc), and msys-base (bash + utilities):

Before attempting to run anything, edit the file C:\MinGW\msys\1.0\etc\fstab. It
must contain:

# Win32_Path                           Mount_Point
#------------------------------------- -----------
C:/MinGW                               /mingw
C:/                                    /c

C:/ is important because it allows bash access to the entire hard drive, otherwise you will only have access to the c:\mingw\msys\1.0 directory.

Next, in C:\MinGW\msys\1.0, copy a link of msys.bat to Start Menu, named bash, so bash can be run from the start menu.

At this point, you can double click on the msys.bat (bash) link and bash will start.

Finally, add c:\mingw\msys\1.0\bin to your path. When done, commands such as ls can be run from cmd.

Installing Other Packages

There are some other packages that I know I would want. These can be installed directly using mingw-get:

mingw-get install msys-vim
mingw-get install msys-wget

Some Operational Notes

You can start bash from inside cmd like this:

bash -l

-l means to run login scripts.

To run a script with bash, you run bash and specify the path as you would inside bash. For example, if I want to run c:\tmp\test.sh, use:

bash -l -c /c/tmp/test.sh

You may or may not want -l. I have an extensive login script that I always want run.

Using scp (or pscp) requires a slightly screwy path as well.

scp myfile /tmp

will work fine.

scp myfile myhost:/tmp

will fail with ssh: Could not resolve hostname myhost;c: No such host is known.

I don’t fully understand what is going on, but myhost:/tmp is not being translated correctly. To get it to work you need two //:

scp myfile myhost://tmp

I have found that I can copy the entire MinGW environment between machines by simply copying c:\MinGW and adding the path.

Conclusion

I’m looking forward to further experiments with MinGW. I don’t have to write many cmd BAT files any more but when I do I just detest them. They are so clunky compared to bash. I would be perfectly happy migrating everything to bash.

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:

WordPress.com Logo

You are commenting using your WordPress.com 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.