If you are new to MinGW, the recommended way to begin is to use the mingw-get-inst GUI installer, which is basically a GUI wrapper to the CLI program mingw-get. If you wish to install from the command line (using mingw-get), do the following:
- Download the mingw-get installer and extract/rename the files to the C:\MinGW directory.
- Add C:\MinGW\bin; to the PATH environment variable.
- Use the mingw-get command to install MinGW as explained in the mingw-get release notes.
Following these instructions will install GCC version 4.5. See also Getting Started for more detailed instructions.
- The recommended installation directory is C:\MinGW. Unless you are very sure you know what you are doing, you should not change this; in particular: never install MinGW into any directory which includes spaces in its absolute path name.
- The installer will not automatically modify any environment settings, (in particular PATH). You will need to add the MinGW `bin' directory, as described below; see Environment Settings.
- For versions of MSYS prior to MSYS-1.0.11; do not install MinGW into the same path as MSYS; (you may install to a subdirectory of the MSYS tree, as long as non-MSYS executables are not placed in the MSYS /bin directory).
- When you install both MSYS and MinGW, and have /mingw mapped to your MinGW directory (as is the default), if you then install ports, supplementary MinGW programs or libraries, you are advised to install them into the /mingw directory tree, to ensure that they will be available for use with GCC; e.g. you should configure with
../path/to/configure --prefix=`cd /mingw; pwd -W`
(This latter form is preferred, when the program being installed is a native Windows binary, and the prefix may be hard coded into the executable).
As an alternative to the automated installer, you may install MinGW by manually downloading and extracting individual components. Please refer to the release notes for detailed notes, including known issues.
Before proceeding, you are encouraged to also consult the release notes for each individual package; links to these will be found adjacent to each package file entry, on the MinGW Download Page.
Download at least the following (or newer) packages from the MinGW Download Page; where two or more component packages are indicated, you need both / all of them. (Note that the package links provided here refer to current releases at the time of writing; these links may not necessarily be updated immediately, when new releases become available):
- mingw-runtime (dev and dll)
- Required runtime libraries for GCC:
- gcc-core (bin and dll)
These are the minimum requirements for a working MinGW GCC toolchain for C.
Optionally you may want to add any of the following additional languages; (for each which you choose to install, you need both the bin and the dll component packages):
- gcc-g++ (bin and dll) for C++
- gcc-objc (bin and dll) for Objective C
- gcc-gfortran (bin and dll) for Fortran 90/95
- gcc-java (not yet available) for Java
- gcc-ada (bin and dll) for Ada
Note that the GCC versions of these files must match the GCC version of the gcc-core installed.
Optionally you may want to add any of the following additional utilities:
- mingw-gdb and libexpat for debugger
- mingw32-make for make
- mingw-utils for MinGW Utilities
- MSYS for Unix-style commands and shell (see the MSYS page for installation instructions)
- msysDTK for Unix-style developer toolkit
You may also want the following additional features:
You will also need a program that can extract .tar.gz and .tar.lzma files, such as 7-Zip or command-line tar, gzip, and lzma tools. A basic standalone tar program bsdtar that includes gz and lzma support is available from the MinGW project.
Create a directory (e.g. C:\MinGW), download all packages to C:\MinGW, extract the files from each package, and add C:\MinGW\bin; to your PATH environment variable as described in Environment Settings below.
The whole C:\MinGW subtree is fully relocatable which means there can be several different versions of the MinGW toolchain installed in parallel, e.g. in directories C:\MinGW-3.4.5 and C:\MinGW-4.5.0. Switching between these is merely a matter of renaming directories, assuming C:\MinGW\bin; has been added to the path. You can permanently add C:\MinGW\bin; to the path by opening the System control panel, going to the Advanced tab, and clicking the Environment Variables button.
Updating single packages (e.g. when there is a new version of the w32api) can be done by copying the new package to C:\MinGW and unpacking as above to overwrite the older version. This manual update also works with an initial automated install.
When you install command line tools, such as MinGW, or GnuWin32 tools, you have to tell the command line interpreter where to find them; this is usually accomplished by adding the appropriate directory names to the PATH variable in your environment. Typically, it is your responsibility to do this; please do not expect the installer, (if you used one), to do it for you.
Warning: Adding entries to the PATH is normally benign. However, if you delete, you may mess up your PATH string, and you could seriously compromise the functioning of your computer. Please be careful.
- Right-click on "My Computer" and select "Properties".
- Click Advanced -> Environment Variables.
- In the box entitled "System Variables" scroll down to the line that says "PATH" and double-click the entry.
- You will be presented with a dialog box with two text boxes, the bottom text box allows you to edit the PATH variable. It is very important that you do not delete the existing values in the PATH string, this will cause all sorts of problems for you!
- Scroll to the end of the string and at the end add ";<installation-directory>\bin". Here <installation-directory> is the full absolute path name of the installation directory; if you accepted the defaults when installing tar and gzip, then for these, it will (probably) be C:\Program Files\GnuWin32, while for MinGW it will be C:\MinGW\bin, (if you kept to the recommended default installation directory). Don't forget the semicolon; this separates the entries in the PATH.
- press OK -> OK -> OK and you are done.