Minimalistic GNU for Windows
These instructions will show you how to download and install the command-line version of MinGW. Most students in CS 150 and CS 250 will be better-served by downloading and installing DevC++, which includes MinGW, instead of following these instructions.
What is MinGW?
MinGW ("Minimalistic GNU for Windows") is a command-line C/C++ compiler and utilities, based on the GNU GCC project. It compiles and links code to be run on Win32 platforms (Win95 through XP). Unlike some other versions of GCC, MinGW uses the Microsoft runtime libraries, distributed with the Windows operating system. Since these runtime libraries are not distributed using GNU's General Public License (GPL), you do not have to distribute your source code with your programs unless, of course, you use a GPL library in your programs.
MinGW comes with everything you need to compile and link both console-mode and GUI programs that will run on Windows 95/98/NT/2K/XP; your programs will not run on Windows 3.1 or on plain DOS machines however.
MinGW does not come with an Integrated Development Environment [IDE]. Instead, you write your source code using a text editor, such as Windows Notepad or SciTE. You then compile, link, and run your programs from the command-line, (that is, an MS-DOS or Command Prompt window.)
The rest of this page will walk you through the steps necessary to download, install, and run your C++ programs using MinGW.
Step 1: Download MinGW
AVisit the main MinGW download site at:
http://www.mingw.org/download.shtml
Locate and click the File List link as shown here:
BIn the file list, locate and click the current version of
MinGW. This will have an .exe extension as shown here:
CThe actual files you download are hosted on mirror
sites around the country. You'll be given a chance to select
a mirror. I usually select the University of North Carolina,
(Chapel Hill), but any of them should be all right.
DWhen the download dialog (below) appears, click Save,
rather than Open:
ESave the file in a download or temporary directory
on your local machine. (Be sure to remember where you put it!).
The downloaded file is about 14.5 MB.
Step 2: Install MinGW
AUsing Windows Explorer, locate the file you downloaded, and
double-click it:
BClick Yes when the
dialog asks you if you want to install
MinGW, as shown here:
CMinGW uses a regular
"InstallShield" type installer. Click Next
when the introductory screen, shown here,
appears:
DRead through the license
and then click Yes to install:

MinGW is released under the GNU Public License,
(GPL), which allows you to obtain
and modify the source code to the compiler.
If you do so, then the changes you make must
also be released under the GPL. However, the
programs you create with MinGW don't
normally link with GPL libraries, so you are
free to distribute the programs you write using
MinGW in any way you wish.
ESelect a folder where
you would like to install MinGW. It's best if
you don't use a folder that contains spaces,
(such as "Documents and Settings"). As you
can see here, I've created a folder named
bin, where I install all of the programs
that I use. Click Next once you've
selected a folder:
FHere's the dialog that
is displayed while the files are decompressed
and installed :
GOnce the files are
copied, click Finish to finalize the
installation:
Step 3: Configure the PATH
Before you can use the compiler and tools, there is one more step you have to complete: you have to modify the PATH environmental variables so that the Command Prompt knows how to find the compiler executable program. (I've never understood why the installation program doesn't do this automatically.) There are two ways to set the PATH variable, depending upon the version of Windows you are using.
AIf you are using Windows 9x, then you'll need to modify (or create) the C:\AUTOEXEC.BAT file. Open the file using Notepad, and add a line like this to the end of the file:
You'll have to reboot your computer after making changes to the AUTOEXEC.BAT file, and before those changes will take effect.
BWith Windows 2000 or
Windows XP, you don't have to modify a file.
Instead, simply right-click on the My
Computer Icon, and select Properties:
CWhen the System
Properties dialog appears, choose the
Advanced tab, and then click the
Enviromental Variables button at the
bottom of the dialog, as shown here, for
Windows XP:
DWhen the Environmental
Variables dialog appears, locate the
Path variable in the Sytem variables
list box, and click Edit as shown here:
EWhen the Edit System Variable dialog appears, add the following to the beginning of the value that already exists:

Click OK, and close all of the open dialog windows.
Step 4: Test Your Installation
AOpen a Command Prompt
window. In Windows 2000 and Windows XP, you'll
find this on the Accessories menu like
this:

With Windows 9X, the Command Prompt is called
the MS-DOS Prompt and you'll find it on
the Start menu.
BUse the CD command to
change to the folder where you keep the files
for your class. In the example shown here, I'm
using a folder called C:\docs\CS250:

If you haven't created a work folder yet, you can
do it now using Windows Explorer. Your life will
be a whole lot easier, if you avoid a folder name
that contains spaces. (In other words, use C:\docs\CS250,
rather than something like
C:\Documents and Settings\Owner\My Documents\CS250.)
CMake sure everything is set up correctly by typing the following command and then pressing ENTER:

If, instead, you see something like this:

it means you made a mistake in Step 3: Setting the PATH. Redo the Step 3, and then test it again with Step 4, until you see a version message, such as that shown here.
Step 5: Compile and Run I
Here are the instructions you'll need to compile and run your programs using the Command Prompt and Notepad. The example shown here will use one file (hello.cpp) that prints "Hello World".
ACreate a folder to hold your project,
using the md command, and then change into the working
directory, using the cd command. Finally, create your
source code file by typing notepad hello.cpp as shown here:

Click Yes when asked if you want to create the
new file, as shown here:

BType in the source code for
your program, as shown here:
CSave your source code, and then switch to the Command Prompt window to compile and run.
To compile, use the command:
To run the program, use the command:
Step 6: Compile and Run II
Here are the instructions you'll need to compile and run your multi-file programs using the Command Prompt and Notepad. The example shown here will use three files:
- hello.h that contains the interface for the class named Hello
- hello.cpp that contains the implementation of the Hello class.
- sayhi.cpp that creates two Hello objects and has them speak.
ACreate a folder to hold your project,
using the md command, and then change into the working
directory, using the cd command. Finally, create your
source code files by typing notepad hello.cpp,
notepad hello.cpp, and notepad sayhi.cpp
as shown here:

Answer Yes each time Notepad asks if you want
to create the new file, just like you did in the previous
example.
BType in the source code for
all three files, as shown here:
CSave your source code, and then switch to the Command Prompt window to compile and run.
To compile, use the command:
To run the program, use the command: