Installing MinGW and MSYS on Windows XP

September 5, 2008

What I’m Up to

I want to install MinGW and MSYS on my computer so I can compile some open source programs. I have only a small amount of experience with Unix from school, and my time with Kubuntu to rely on. It should be a fun learning experience, but setting up a build environment with MinGW / MSYS is quite complicated.

I’m not taking anything away from the MinGW guys, because the work they do is very hard, and greatly beneficial to those who use open source software on Windows. Even so, I feel it necessary to blog about this, if only as a record of my attempts for my own future reference. Please don’t assume anything I post about MinGW / MSYS is authoritative, or necessarily even correct. If you want to know the truth, try downloading MinGW / MSYS and working with it on your own.

Relevant Links (Home page of MinGW and MSYS) (Project page of MinGW and MSYS on Sourceforge) (Vim home online) (“Mastering the VI editor”: University of Hawai`i, College of Engineering, Computer Facility) (Home page of the GNU Compiler Collection) (UNIX / Linux Tutorial for Beginners)

My Computer

HP Pavilion dv8135nr, Windows XP Media Center Edition (Service Pack 3)

About Package Versions

I’m downloading the versions of each package that are available as I write this. In the future there will be newer versions of these packages, so don’t expect your experience to be the same if the version numbers aren’t the same. By all means please download the latest versions, and find your own way as you go.

MinGW Installation

Note: It is advised to install MinGW first. The MSYS installer will normalize to your existing MinGW installation.

Download the Automated MinGW Installer, version 5.1.4 as of this post, from the link below:

click to expand image

Create the folder C:\MinGW and save the downloaded file there. Now you sould have the file C:\MinGW\MinGW-5.1.4.exe.

Important Note: Never install MinGW or MSYS on a path containing spaces!

Double click the MinGW-5.1.4.exe file to run the Automated MinGW Installer.

Note: When the installer runs for the first time, it will perform a quick update check, and then create the mingw.ini file to record information about your installation.

Follow along to answer the prompts as shown. Prompts are shown in italics, and actions you should take are in parentheses.

Welcome to MinGW . . . (Click Next)

Install or just download files? (Choose Downlaoad and install, then click Next)

License Agreement (Click I Agree)

Choose Package (Choose Current, then click Next)

Choose Components (Checkmark MinGW base tools and g++ compiler, then click Next.)

Note: Do not checkmark MinGW Make!

Choose Install Location (Note the default location of C:\MinGW and click Next)

Choose Start Menu Folder (Click Install)

Note: If the Automated MinGW Installer fails for any reason, check your Internet connection, and run the Automated MinGW Installer again.

Downloading . . . (Wait and observe the process)

Extracting . . . (Wait and observe the process)

Installation Complete (Note the intallation log, then click Next.)

MinGW has finished . . . (Click Finish.)

Note: The Automated MinGW Installer has downloaded and extracted all required packages to the C:\MinGW folder.

click to expand image

Note: The Automated MinGW Installer has also placed shortcuts in the Windows All Programs menu and Add or Remove Programs applet of the Control Panel.

MSYS Installation

Download the MSYS Base System installer from the link below. Be sure to get the Current Release, version 1.0.10 as of this post.

Note: It may be necessary to scroll your browser window, or drill down the menu, until you find Current Release: msys-1.0.10.

click to expand image

Create the folder C:\MSYS and save the downloaded file there. Now you should have the file C:\MSYS\MSYS-1.0.10.exe.

Important Note: Never install MinGW or MSYS on a path containing spaces!

Double click the MSYS-1.0.10.exe file to run the installer, and answer the prompts as follows. Prompts are shown in italics, and actions you should take are in parentheses.

This will install “Minimal SYStem”. Do you wish to continue? (Click Yes)

Welcome to the “Minimal SYStem” . . . (Click Next)

License Agreement (Click Yes)

Information (Read the information, then click Next)

Select Destination Directory (Note the default location of C:\msys\1.0, then click Next)

Select Components (Accept the default of i386 based CPUs, and click Next)

Select Start Menu Folder (Click Next)

Ready to Install (Be sure the installation settings are correct, then click Install)

The installer now runs a small batch program to complete the installation.

MSYS Post Install Process

The batch program will open in a command line window, and prompt you to answer a few simple questions. You must be especially careful in answering the prompts because the batch program may misunderstand a mistyped response.

click to expand image

Note: Be sure to follow along carefully as the batch program will not give you a chance to correct any mistakes!

Read the texts in the command window fully, and answer the prompts as follows. Prompts are shown in code style, and actions you should take are in (parentheses).


This is a post install process that will try to normalize between
your MinGW install if any as well as your previous MSYS installs
if any. I don't have any traps as aborts will not hurt anything.
Do you wish to continue with the post install? [yn ]

(Type the lower case letter y, then type the enter key)

click to expand image

Note: By type I mean you should press and quickly release the key.

Do you have MinGW installed? [yn ]

(Type the lower case letter y, then the enter key)

Note: Pay special attention to the path delimiters used in the next prompt because we are expected to use the forward slash, usually found on the same key as question mark.

Please answer the following in the form of c:/foo/bar.
Where is your MinGW installation?

(Type the full path of the MinGW folder in the format shown by the prompt.)

Note: Recall that we chose the location C:\MinGW during the MinGW installation process.

Note: If you typed the path incorrectly, perhaps by using anything other than the forward slash as a path delimiter, then you’ll be required to manually edit the /etc/fstab file after completing MSYS installation.

There will be no further interaction with the batch program after you press the enter key. If you typed all responses correctly up to this point, then the command prompt window will look like the image below.

click to expand image

(Type the enter key.)

Creating /etc/fstab with mingw mount bindings.
Normalizing your MSYS environment.

You have script /bin/awk
You have script /bin/cmd
You have script /bin/echo

You have script /bin/egrep
You have script /bin/ex
You have script /bin/fgrep
You have script /bin/printf
You have script /bin/pwd
You have script /bin/rvi
You have script /bin/rview
You have script /bin/rvim
You have script /bin/vi
You have script /bin/view

Oh joy, you do not have c:/MinGW/bin/make.exe. Keep it that way.

Press any key to continue . . .

(Type the enter key one time to proceed)

click to expand image

Note: Observe that we are advised not to install MinGW Make.

Now we go back to the Setup – “Minimal SYStem” installer window. The process is complete.

Setup has finished installing “Minimal SYStem” . . . (Click Finish)

Note: If you left the two boxes check marked, as you should have, you will see two document windows with important texts which you should now read.

click to expand image

Note: You can read the MSYS documentation again later. They are located at C:\MSYS\1.0\doc, if you’ve followed along.

click to expand image

Note: MSYS is installed to the path C:\MSYS\1.0, which will become the root of the MSYS virtual file system.

click to expand image

Note: Shortcuts for MSYS have been added to the Windows desktop, All Programs menu, and Add or Remove Programs applet of the Control Panel.

Write a Test Program

We’ll create a simple C program and compile it with GCC to test our installation.

Start by double clicking the MSYS icon on your desktop, or clicking the MSYS icon in your Start menu’s All Programs sub menu. Alternatively, you may also start MSYS by executing the C:\MSYS\1.0\msys.bat batch program.

MSYS opens an rxvt terminal with a Unix command prompt. If you are not familiar with Unix, then you’ll need a good tutorial on the subject. I’m not teaching Unix here, but I encourage you to learn Unix if you have the patience.

click to expand image

I’ll be using the Vim text editor which is included with MSYS. Be advised that the MSYS package has omitted the Vim documentation. If you don’t know Vim, then I strongly advise you to read a good tutorial first. Teaching you to use Vim is far, far beyond the scope of this post.

IMPORTANT NOTE: Many people have floundered hopelessly on their first encounter with Vim, myself included. Some people love Vim for it’s power and efficiency, and justifiably so, but I am not one of them. I’m hoping to successfully compile Emacs later, but feel free to use Vim all you like if it suits you better.

In the MSYS terminal, create a directory named hello in your home directory and change to the new directory.
mkdir ~/hello
cd ~/hello

Now enter the command vim hello.c to begin editing the C source code file.
vim hello.c

Type in the code, shown below in preformatted style. Write the file to disk, and quit from Vim.
#include <stdio.h>

int main(void) {
printf("Hello, World!");
return 0;

Note: If you have any difficulty editing the source code in Vim, then please go to the tutorial and read it. Don’t say you weren’t warned!

Now compile the code with GCC:
gcc -ohello.exe hello.c
Test the compiled code by running the generated executable:

If the hello message is printed and no errors are reported, then you’re good to go with MinGW and MSYS!


One Response to “Installing MinGW and MSYS on Windows XP”

Leave a Reply

Please log in using one of these methods to post your comment: 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

%d bloggers like this: