Revision of <em>Getting Started</em> from <em>2011, February 1 - 18:14</em>

This page will guide you through a typical, one size fits all, installation of MinGW. If you are new to MinGW, you may wish to refer to the MinGW page to learn which tools it installs (referred to as packages), and which tools perform which tasks. For more advanced installation instructions, refer to HOWTO Install the MinGW (GCC) Compiler Suite. There is also some introductory information for users who are new to MinGW.

MinGW Installation Notes

MinGW may have problems with paths containing spaces, and if not, usually other programs used with MinGW will experience problems with such paths. Thus, we strongly recommend that you do not install MinGW in any location with spaces in the path name reference; i.e. you should avoid installing into any subdirectory of "Program Files" or "My Documents", or the like.

No version numbering convention exists for MinGW as a whole. Each package has its own version number, and the installer version number does not necessarily reflect the version number of any individual package which it installs.

Graphical User Interface Installer

The GUI installer is a graphical user interface to the CLI mingw-get installer described below. To use it:

Select the directory to install MinGW, remembering the advice given above that the path to this directory should not contain any spaces.

Select the optional components to be installed, including the C++, Fortran, Objective-C, and Ada compilers and MSYS.

The GUI installer will then download and run the mingw-get CLI installer to install GCC version 4.5. Note that make and gdb are installed automatically by the GUI installer. Before using MinGW, you should add C:\MinGW\bin; to the PATH environment variable using the instructions provided below.

Command Line Interface Installer

The recommended tool for automated installation is mingw-get; although currently designated 'alpha', this is already capable of installing GCC 4.5 and the basic (optional) MSYS shell environment recommended to support it. (Do note, however, that since it is still under development, we may ask you to manually perform some follow-up actions, which you might rightfully expect the installer to complete for you; eventually it will, but in the meantime, please bear with us).

Download the latest version of the mingw-get installer and extract the files to the C:\MinGW directory using a program that can extract zip files. Recent versions of Windows may support this directly from the Windows Explorer; alternatively you may use a program such as 7-Zip.

Add C:\MinGW\bin; to the PATH environment variable by opening the System control panel, going to the Advanced tab, and clicking the Environment Variables button. If you currently have a Command Prompt window open, it will not recognize the change to the environment variables; you will need to open a new Command Prompt window to get the new PATH.

At the Command Prompt, cd to bin and type the command

mingw-get install gcc

to download and install the C compiler, and its requisite support packages; (mingwrt, w32api and binutils, for those interested).Additionally, you can specify any or all of the following additional packages:

g++ (C++ compiler)

fortran (Fortran 90/95 compiler)

ada (Ada compiler)

java (Java compiler)

objc (Objective-C compiler)

mingw32-make (GNU make)

gdb (GNU debugger)

msys-base (MSYS shell environment)

For example, the command

mingw-get install gcc g++ mingw32-make

will install the C compiler, C++ compiler, and make utility.You can install more additional packages at any time. For example, the command

mingw-get install fortran gdb

will add the Fortran 90/95 compiler and debugger to the existing installation.If you choose to also install 'msys-base', note that its default installation path is 'C:\MSYS\1.0', and the easiest way to start the shell is by running the msys.bat file found in that directory. You may also wish to run the command

/postinstall/pi.sh

within the MSYS shell, the first time you start it. (This is a temporary measure, to establish bindings between your MinGW and MSYS installations; it will become unnecessary, when a post-install scripting capability is added to mingw-get).

Environment Settings

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.

Cautions

The installer does not automatically modify any environment settings, (in particular PATH). You will need to add the MinGW `bin' directory, as described: 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). You probably don't have to worry about this.

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=/mingw

or

../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).

Manual Installation

As an alternative to the automated installer, you may install MinGW by manually downloading and extracting individual components. Please refer to HOWTO Install the MinGW (GCC) Compiler Suite for information on manual installation.

I was trying to install the mingw in the order of files that is above (binutils, mingw-runtime, w32api...) and when I was trying to install the gcc core, appeared a message asking me about overwrite a file called "libiberty" (I don't remember in this moment the extension). What libiberty is the correct to leave, the first or the libiberty that is in the gcc core?

It doesn't matter which one you keep. The libiberty.a file is an artifact of both binutils and gcc with the unfortunate side affect of the file being installed with the ``make install command which is the real error here. The two packages should never install the file but the way the iberty library is packaged within both with a separate ``make install' command allows this to happen. The iberty library is packaged with each because of both the GPL and the GNU Coding Standard.

You cannot use MinGW-5.1.6.exe to install any version of GCC later than 3.4.5. Neither can you gerrymander it, to build from sources downloaded from any repository other than our own SF distribution; it requires the pre-built binary package files, which we provide.

What you are trying to do is both unsupported and impossible, with the deprecated installer package you are trying to use.

I notice that someone has very helpfully updated this page according to information from the "release notes". Could someone add a link to the release notes on this page? That would also be very helpful. Also, does one need to install both the "bin" and "dll" versions of the packages, or just one of them? In either case, it would be very helpful to disambiguate the commas to either "and" or "or", or if punctuation is preferred, "&" or "/". Thanks!

This may be a trivial problem but in spite of updating the path variable (c:\MinGW\bin), gcc/g77/etc. does not work from command line. It works fine in the c:\MinGW\bin directory as well as on my other computer. I am not sure what the problem could be. Any suggestions?

I need advice on how to install gdb manually. I have two download files:

gdb-6.8-mingw-3-patch

gdb-6.8-mingw-3.tar.gz2

I plan to use the .tar.gz2 download for the installation and your instructions for that seem clear enough. Is the patch file required for this installation? That is, do I need to apply the patch file to the extracted content from the .tar.gz2 archive or is the patch file only used with the src download?

GDB is an entirely separate product from GCC. It is not a prerequisite for running GCC, as are the majority of other packages which are installed by MinGW-5.x, and hence it is not imperative that MinGW-5.x should install it. However, the same argument for exclusion could be applied, in the case of mingw32-make, which is included; conversely, the inclusion of mingw32-make sets a precedent for the possible inclusion of GDB. Ultimately, the decision on that is down to the package maintainer; since MinGW-5.x is currently unmaintained, don't expect it to happen any time soon.

mingw-get, when it eventually becomes available, will install any package -- and optionally all of them -- which is distributed by the MinGW Project.

I'm confused by your reference to gdb-6.8-mingw-3.tar.gz2, for there is no such thing as gz2 compression; it is either bz2 or gz. In this case, I assume you mean the binary release file gdb-6.8-mingw-3.tar.bz2, rather than the source tarball, gdb-6.8-mingw-3-src.tar.gz.

The gdb-6.8-mingw-3-patch file, to which you refer, (and by which I assume you mean gdb-6.8-mingw-3.patch), details the source code changes to mainline gdb-6.8 sources, which were applied to achieve this gdb-6.8-mingw-3 release candidate, (which strictly, should be called gdb-6.8-mingw32-3). They are of interest only to those integrating mingw32 support into mainline GDB; you do not need them, if your only interest is in deployment of gdb-6.8-mingw-3.tar.bz2. (It isn't immediately obvious if these patches have already been incorporated into the local sources, gdb-6.8-mingw-3-src.tar.gz -- I am not the maintainer of this package -- but the naming convention would suggest that they have).

I agree it would be convenient to include gdb. how many programmers are there who want to install a compiler and don't want to also install the debugger?

at the least, it would be useful to just outline the basic steps to install gdb. I downloaded the same files as darrenleeweber and had the same questions-- minGW's default installation (at least with g++ alone) does not include bzip2, nor are there any instructions on how to install these packages. here's what I did after downloading the binary gdb distro. I haven't used gsb before so I can't guarantee this approach works properly, but fyi:
1. download the bzip2 executable from http://www.bzip.org/downloads.html, rename to "bzip.exe" and put in a path folder (e.g. c:\minGW\bin). in the following, I assume you use c:\minGW as the base minGW folder
2. if you don't have it, install winzip or 7-zip
3. unpack the tarball: C:\MinGW> bzip2 -d C:\MinGW\gdb-6.8-mingw-3.tar.bz2
4. using winzip or 7-zip, unpack the resulting gdb-6.8-mingw-3.tar file to folder "gdb-6.8-mingw-3". I did not try to, and do not recommend you try to, extract into the current directory, since it could overwrite some of your shared libs etc that are being used for the rest of your minGW platform.
5. copy gdb.exe into C:\MinGW\bin. one possible problem with this is that gdb.exe might not be consistent with the versions of libs and other shared files in the minGW platform you have installed. It seemed to work for me using minGW 4.4.

It would be nice if the automated installer gets updated and restructured a little bit... I know, there is no time, but the installation process could be a little easier. It would be great if one could choose a major version instead of previous, current, candidate.... I mean candidate what? Then the mingw project has a lot of extra utilities that could be bundled with the download as well, like gdb or msys! yes very nice utilities! It would break the confusion between all the different download packages one has at sourceforge, since there is no real documentation about what belongs to what and which package is stable.

If you don't have a favourite mirror, or you don't know its name, please choose one from the list here, (or use `osdn', for SourceForge's master repository, which might help to annoy them into fixing their bug a bit quicker).