Revision of Getting Started from 2013, July 13 - 20:56

Printer-friendly version

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. You should avoid installing into any directory or subdirectory having names like "Program Files" or "My Documents", etc.

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

The preferred installation target directory is C:\MinGW

The preferred installation method is using the automated installer tool. While a manual installation is possible, we do not reccommend it. Instructions are provided below if you really want to risk it.

After installation you will need to perform some additional tasks yourself to ensure your MinGW applications will run. Most importantly, you will need to make changes to your PATH environment variable. Be careful: there are two PATH variables which can be changed, and changing the wrong one can have significant consequences. Instructions for changing the correct PATH variable are provided below.

You will also need to ensure you specify the correct installation target directory to the MinGW environment. While it is possible to install MinGW to a location other than C:\MinGW (ie on a different drive), you must ensure that the MinGW environment knows where it is located. Instructions for doing this are also provided below.

Graphical User Interface Installer

An automated GUI first time installer tool called mingw-get-inst is currently the preferred method of installation.

The mingw-get-inst tool will only facilitate the initial set up of the CLI (Command Line Interface) mingw-get installer. Note that the mingw-get-inst tool is not an official GUI installer; it is intended for first time use only, to set up the CLI installer which should be used for all subsequent updates or modifications.

An official GUI installer is currently under development, but remains temporarily unpublished. For those willing to assist with the evaluation and testing of the GUI installer development snapshots, these will be made available from the developer's personal SourceForge project pages, (see below).

To use the mingw-get-inst automated first time installer tool, do the following:

  1. Click on this mingw-get-inst link to take you to the installation tool server directory.
  2. Click on the directory that has the most recent date string (yyyymmdd) in its name.
  3. Locate the file named "mingw-get-inst" ending in ".exe", and having the most recent date string (yyyymmdd) in its name.
  4. Click on that link and save the file to your local hard drive.
  5. Locate the file you have downloaded, and double click on it to start the installer.
  6. Locate the directory into which you want to install MinGW (ie C:\MinGW). Use the advice given above: that the absolute path to this directory should not contain any spaces.
  7. Select the option to update package catalogues to latest available. NOTE: If you attempt to use the bundled catalogues, you may install a hopelessly out-of-date system.
  8. Select the optional components to be installed, including the C++, Fortran, Objective-C, and Ada compilers and MSYS.
  9. The set up tool will download and run the mingw-get CLI installer, to install the selected component packages. NOTE: The make and GDB packages are installed automatically by the set up tool.

NOTE: The preferred installation is to always include the MSYS addon, regardless of other packages you also choose.

NOTE: In many cases, you will probably need to add the C++ compiler as well

(The MinGW release notes contain more detailed information about the configuration and use of the mingw-get-inst set up tool).

After Installing You Should

If you used the automated installation tool and installed MSYS as an addon to MinGW, you do not need to change your PATH environment variable.

If you used either of the GUI installers (the mingw-get-inst tool or the unofficial installer snapshot), and you installed the MSYS add on, they will create a start menu "MinGW Shell" shortcut in your "Start \ Programs \ MinGW" folder. Double clicking the shortcut will open a command window with the correct environment setup for you, including the correct path references, allowing you to run any of the MinGW or MSYS applications within that command window.

Regardless of how you installed MinGW or MSYS, you should check your MSYS configuration (if you have installed MSYS). You need to ensure that MSYS knows where it is located:

  1. Open a Windows Explorer window and locate your installation directory (ie C:\MinGW)
  2. Below your installation directory, you should find a directory named "msys" in lower case letters.
  3. Find (and open) the additional subdirectories "1.0" and "etc".
  4. Within the "etc" directory, there is a file named "fstab". Open it with a text editor. You should be able to do this by right clicking on it, and in the popup menu select "Open" or "Open With"
  5. Edit the file and ensure that it reads as follows:
<installation-directory>   /mingw

NOTE: Substitute <installation-directory> with the FULL and absolute path to where you installed MinGW (ie C:\MinGW). Make sure you follow the <installation-directory> entry with at least one space before typing the "/mingw" entry.

NOTE: Before you save the file, make sure there is at least one blank line at the bottom below all of the entries that may exist, then save and close the file.

Your MinGW and MSYS installations should now be ready for use.

Caveats: (exceptions)

If you ever intend to run MinGW or its applications using a cmd.exe window, you will need to make changes to your PATH environment variable. Instructions for doing so are listed in the Environment Settings section below.

Updating or Changing Your MinGW or MSYS Installation

There are two options for updating, adding, or removing components from your installation:

  • Using GUI Installer Development Snapshots
  • Using the CLI (Command Line Interface) Installer

Both methods will allow you to modify the original installation packages, in addition to the following available addon packages:

  • C++ (actually g++)
  • 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)

Using GUI Installer Development Snapshots

After you have completed the first time set up (described above) you are expected to use the CLI Installer (described below) to manage and update your MinGW installation.

If you are uncomfortable with using the CLI, you may wish to consider running a development snapshot of the GUI Installer. You can also participate in the development and testing of the GUI version of the installer. Even if your participation is limited to offering suggestions based on your user experience, your input will be greatly appreciated.

Currently, development snapshots are made available here, on an ad-hoc basis. To install the latest snapshot:

  • First download and run the mingw-get-setup.exe tool, (or run it directly from the SF server, if your browser and system policies will permit it).
  • In the opening dialogue, confirm that you wish to proceed with the "Install" option.
  • Select your installation preferences, from the ensuing dialogue, followed by "Continue".
  • If mingw-get-setup complains that mingw-get is already installed, either go back and select an alternative (clean) installation directory, or select "Reinstall"; (the reinstall choice is safe, it will overwrite only mingw-get, replacing it with the most recent version; it will not affect the state of any other MinGW.org packages which are already installed).
  • When download and installation of mingw-get itself has been completed, (and provided you chose the option to install the GUI component), the "Continue" option will immediately invoke the GUI installer, to allow you to install additional MinGW.org packages; (note that this currently differs from the operation of mingw-get-inst, in that there is no initially restricted choice of common packages. Since this may appear less friendly to first-time users, a (near) future snapshot will provide this capability).
  • After completing these steps, you may invoke the GUI Installer from the shortcut in your start menu, or directly from the command line, by invoking:
    mingw-get

    without specifying any argument.

Using the Command Line Interface Installer

The tool used for command line installation is called mingw-get. Note that it differs from mingw-get-inst. Although currently designated as a 'beta' release, mingw-get is capable of installing GCC 4.x and the basic (optional) MSYS shell environment recommended to support it.

Since it is still under development, we ask that you 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 freeware program such as 7-Zip.

After extracting the files, you will need to make changes to your user PATH environment variable. See the instructions in the section "Environment Settings" below now.

You should also read the section "After Installation You Should" above.

After changing your user PATH, you will need to open a new Command Prompt window. Click on "Start \ Run" and enter "cmd" then click "OK".

At the Command Prompt, 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).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 now 'C:\MinGW\MSYS\1.0'. The easiest way to start the shell is by running the msys.bat file found in that directory.

The first time you start the shell, you may also wish to run the command:

/postinstall/pi.sh

This is only a temporary measure to establish bindings between your MinGW and MSYS installations. The command will become unnecessary, when appropriate post-install scripting is added to the MSYS package catalogues.

The mingw-get release notes contain more detailed information about the configuration and use of the mingw-get installer. GCC documentation, make documentation, and GDB documentation are available online.

Cautions

  • The installers do not automatically modify any environment settings, (in particular the PATH). You will need to add the MinGW `bin' directory, as described in the "Environment Settings" section below.
  • Administrative note The MinGW team do not recommend modifying the Windows PATH variable system wide. We prefer that you use a script to set PATH for the processes on a per session basis. This is the reason that we do not adjust the PATH.
  • 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 dependency 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).

  • Additional information can be found in the HOWTO and FAQ sections.

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 user environment. The installers will not do this for you.

NOTE If you choose to alter your PATH variable, you must ensure you alter your user PATH variable, not your system PATH variable -- there are two of them!

NOTE The MinGW team do not recommend modifying the system wide Windows PATH variable. We prefer that you use a script to set PATH for the processes on a per session basis. See the notes in the "After Installation You Should" section above.

Warning: Adding entries to the PATH is normally harmless. However, if you delete any existing entries, you may mess up your PATH string, and you could seriously compromise the functioning of your computer. Please be careful. Proceed at your own risk.

  1. Right-click on your "My Computer" icon and select "Properties".
  2. Click on the "Advanced" tab, then on the "Environment Variables" button.
  3. You should be presented with a dialog box with two text boxes. The top box shows your user settings. The PATH entry in this box is the one you want to modify. Note that the bottom text box allows you to change the system PATH variable. You should not alter the system path variable in any manner, or you will cause all sorts of problems for you and your computer!
  4. Click on the PATH entry in the TOP box, then click on the "Edit" button
  5. Scroll to the end of the string and at the end add
    ;<installation-directory>\bin
  6. press OK -> OK -> OK and you are done.

NOTE: Substitute <installation-directory> with the FULL absolute path name of the installation target directory you chose (ie C:\MinGW);

NOTE: If you installed MSYS, you may also want to add ";<installation-directory>\MSYS\1.0\local\bin", and ";<installation-directory>\MSYS\1.0\bin" to the end of your user PATH variable.

More Information

More information on Configuring and Using mingw-get is available.

Manual Installation

Manual installation, as an alternative to the use of the automated installer described above, is not recommended; nevertheless it is possible. If you wish to pursue this option, you may install MinGW by manually downloading and extracting individual components. Please refer to HOWTO Install the MinGW (GCC) Compiler Suite for (possibly outdated) information on manual installation.

Re: Getting Started

yes

Re: Getting Started

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?

Re: Getting Started

earnie's picture

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.

MinGW 5.1.6 Error: mismatched long filename

1)---------------download------------------

MinGW-5.1.6.exe, binutils-2.20-1-mingw32-bin.tar.gz, mingwrt-3.16-mingw32-dev.tar.gz, mingwrt-3.16-mingw32-dll.tar.gz, w32api-3.14-mingw32-dev.tar.gz, make-3.81-20090914-mingw32-bin.tar.gz from sourceforge.net, and

gcc-core-4.4.2.tar.gz, gcc-g++-4.4.2.tar.gz, gcc-fortran-4.4.2.tar.gz, gcc-ada-4.4.2.tar.gz, gcc-java-4.4.2.tar.gz, gcc-objc-4.4.2.tar.gz from gcc.gnu.org mirror ftp

2)-----------modify mingw.ini like this:-------------

[mingw]

Build=12

URL=file://e:\network\download\mingw

Filename=MinGW-5.1.6.exe

packages=previous|current|candidate

[current]

runtime=mingwrt-3.16-mingw32-dev.tar.gz|7616

runtimeDLL=mingwrt-3.16-mingw32-dll.tar.gz|40

w32api=w32api-3.14-mingw32-dev.tar.gz|14420

binutils=binutils-2.20-1-mingw32-bin.tar.gz|26979

core=gcc-core-4.4.2.tar.gz|7712

gpp=gcc-g++-4.4.2.tar.gz|15480

g77=gcc-fortran-4.4.2.tar.gz|5272

ada=gcc-ada-4.4.2.tar.gz|33860

java=gcc-java-4.4.2.tar.gz|43160

objc=gcc-objc-4.4.2.tar.gz|3720

make=make-3.81-20090914-mingw32-bin.tar.gz|723

3)-----------------------install mingw 5.1.6---------------------------

disconnect->run mingw.exe->"download and install"->"current"->"full"->c:\mingw

it start correctly but, there's always an error message while extracting gcc-g++-4.4.2.tar.gz :

Writing gcc-4.4.2/libstdc++-v3/testsuite/26_numerics/adjacent_difference/1.cc

tgz_extract: mismatched long filename

Error: Failure reading from tarball.

my OS: windowsxp sp3

file system: ntfs

Re: MinGW 5.1.6 Error: mismatched long filename

keith's picture

Please read the article again.

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.

Re: Getting Started

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!

Re: Getting Started

The release note for MinGW GCC 4.4.0 can be found here.

http://sourceforge.net/project/shownotes.php?release_id=691876

Re: Getting Started

After reading all the comments so I could complete the installation, thanks!

Re: Getting Started

very use full article thanks alot and thats so nice

Re: Getting Started

Hello,

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?

With kind regards,
Pawel

Re: Getting Started

Pawel,

I just installed and had exactly the same problem.
It's not that obvious, you need to set the mount
point of the MinGW directory in the Msys environment.

as a start, just try coping /etc/fstab.sample to /etc/fstab and
restarting the msys..

cheers

Mike

Re: Getting Started

Hi guys.

Will mingw work on future versions of windows?

I'm upgrading to Vista in a short time and i want to know how much 'upgrading' will make me suffer.

My guess is that you guys at Mingw should develop a new version for Vista?

Or is it just the same? What about the Win32 Api? There are surely additions with newer versions of windows.

Thanks.

---
mago

Re: Getting Started

keith's picture

I find it really insulting, when someone says "you guys should...".

This is an Open Source project, developed by volunteers in their spare time. You have no right to tell me what I should, or should not do with my spare time. Why should I, rather than you do that?

AFAIK, MinGW already does work with Vista, but why don't you just try it, and see; then contribute on the basis of your experience, either in the form of patches, or failing that, bug reports?

Re: Getting Started

Please include the gdb package in the automatic installer.

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?

Thanks!

Re: Getting Started

keith's picture

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

Re: Getting Started

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.

Re: Getting Started

Keith, g++ link worked. Thanks for your time.

Re: Getting Started

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.

Re: Getting Started

keith's picture

What you describe is very much what we hope to provide, with the `mingw-get' package currently under development; however, there is currently no forecast as to when this may become available.

Re: Getting Started

which environment is used to let GCC find the include and library in? There are 2 reasons I do this:

1. I do not like to install some c-lib to my MINGW directory, because I don't use it frequently. I can delete them easily - is there any other method do something like "make uninstall"?

2. I do like to install 3rd-part lib into /local, which is h:\mingw\msys\local, to make my MINGW clean and small

and on windows, I have tried 2 types(let's think "lib" is used to search libaray files)

[code, which is added in a batch file ]

set lib=h:\mingw\msys\local\lib;%lib%

set include=h:\mingw\msys\local\include;%include%

[/code]

or

[code, which is added into profile or typed in msys]

set LIB=/h/mingw/msys/local/lib:$LIB

set INCLUDE=/h/mingw/msys/local/include:$INCLUDE

[/code]

but none works. I have always to add

[code]

-I/h/mingw/msys/local/include -L/h/mingw/msys/local/lib

[/code]

to the gcc command-line by hand. That make me tired.

So is there any hints to set the environment automatically everytime to save my time?

thanx

Re: Getting Started

keith's picture

See IncludePathHOWTO and SpecsFileHOWTO, (and do heed my comment following the latter).

Re: Getting Started

The G++ download is dead...

Re: Getting Started

The gcc-g++ download link works OK for me.

Re: Getting Started

SourceForge self-extractor:

  • Extracting gcc-g++-3.4.5-20060117-3.tar.gz
  • untgz::extract -d 'C:\add\MinGW' -z 'C:\add\gcc-g++-3.4.5-20060117-3.tar.gz'
  • tgz_extract: bad header checksum
  • Error: Failure reading from tarball.

Re: Getting Started

I had the same problem.

Manually downloading the file made the install successful.

Re: Getting Started, gcc-g++...tar.gz

I have the same problem, the gcc-g++-3.4.5-20060117-3.tar.gz does not install
I cannot open it like the other files with winzip

Re: Getting Started, gcc-g++...tar.gz

SourceF@#$e is acting up. It looks like its sending people to this URL to download the g++:

http://.dl.sourceforge.net/sourceforge/mingw/gcc-g++-3.4.5-20060117-3.tar.gz

Just take the leading dot out and drop it in the same dir as your MinGW install and you should be good to go.

http://dl.sourceforge.net/sourceforge/mingw/gcc-g++-3.4.5-20060117-3.tar.gz

Re: Getting Started, gcc-g++...tar.gz

Since the mirror is missing in the link for gcc-g++-3.4.5-20060117-3.tar.gz, entering the following worked for me:
http://sourceforge.net/project/downloading.php?group_id=2435&use_mirror=superb-west&filename=gcc-g%2B%2B-3.4.5-20060117-3.tar.gz&a=49476444
I just put the user_mirror=superb-west (which I noticed for other packages).

Re: Getting Started, gcc-g++...tar.gz

keith's picture

That doesn't work, for me -- it just jumps to the top level `files' page.

The correct format for the direct link is actually:

http://<your-favourite-mirror>.dl.sourceforge.net/sourceforge/mingw/gcc-g++-3.4.5-20060117-3.tar.gz

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

Re: Getting Started, gcc-g++...tar.gz

Those links work perfect for me, I have downloaded and uncompressed the files succesfully,

Thanks

Re: Getting Started, gcc-g++...tar.gz

Hí,

I can´t download the g++ files. Link broken.

What can I do?

Re: Getting Started, gcc-g++...tar.gz

keith's picture

Duh? What about reading the comments above, which tell you exactly that?

Site Status

Site maintenance completed May 25th, 2012 at 12:38 UTC