TODO: Revise untar instructions.
The automated installer is out-of-date and until the new mingw-get installer is finalized, you'll need to download the files for the compiler manually and decompress and unarchive them in your MinGW directory (top level directory where you wish to install MinGW, usually c:\mingw).
To help simplify this task, below is a script that will download the files for you. The files to download are for version 4.5.0 of the gnu C/C++ compiler with latest updates as of 6/1/2010. You may need to update this script if later files are released or in order to add other languages. The script requires bash and wget. Both are available from the MinGW file downloads. wget is also available from the gnuwin32 site at Sourceforge. Bash is also available with the djgpp compiler. You can run the script within msys or standalone, just make sure bash and wget are in your path.
Quick links to wget and bash alternatives that don't require msys installed:
To run, type and enter within msys or from a Windows command prompt:
The source code for mingwdl.sh follows:
#!/bin/bash ARCHIVEDIR=/mingw EXTBIN=mingw32-bin.tar.gz EXTDEV=mingw32-dev.tar.gz EXTDLL=mingw32-dll.tar.gz EXTLZMABIN=mingw32-bin.tar.lzma EXTLZMADEV=mingw32-dev.tar.lzma EXTLZMADLL=mingw32-dll.tar.lzma if [ ! -d $ARCHIVEDIR ] then mkdir $ARCHIVEDIR fi cd $ARCHIVEDIR NAME=binutils VERSION=2.20.1-2 SRC=$NAME-$VERSION-$EXTBIN echo "mingw binutils: " $SRC LINK="http://www.mirrorservice.org/sites/download.sourceforge.net/pub/sourceforge/m/project/mi/mingw/MinGW/BaseSystem/GNU-Binutils/binutils-2.20.1" if [ ! -f $ARCHIVEDIR/$SRC ] then wget "$LINK/$SRC" fi NAME=mingwrt VERSION=3.18 SRC=$NAME-$VERSION-$EXTDEV echo "mingw runtime: " $SRC LINK="http://www.mirrorservice.org/sites/download.sourceforge.net/pub/sourceforge/m/project/mi/mingw/MinGW/BaseSystem/RuntimeLibrary/MinGW-RT/mingwrt-3.18" if [ ! -f $ARCHIVEDIR/$SRC ] then wget "$LINK/$SRC" fi SRC=$NAME-$VERSION-$EXTDLL echo "mingw runtime: " $SRC if [ ! -f $ARCHIVEDIR/$SRC ] then wget "$LINK/$SRC" fi NAME=w32api VERSION=3.14 SRC=$NAME-$VERSION-$EXTDEV echo "mingw win32 API: " $SRC LINK="http://www.mirrorservice.org/sites/download.sourceforge.net/pub/sourceforge/m/project/mi/mingw/MinGW/BaseSystem/RuntimeLibrary/Win32-API/w32api-3.14/" if [ ! -f $ARCHIVEDIR/$SRC ] then wget "$LINK/$SRC" fi NAME=mpc VERSION=0.8.1-1 SRC=$NAME-$VERSION-$EXTLZMADEV echo "mingw mpc (Math Precision library for Complex numbers): " $SRC LINK="http://www.mirrorservice.org/sites/download.sourceforge.net/pub/sourceforge/m/project/mi/mingw/MinGW mpc/mpc-0.8.1-1" if [ ! -f $ARCHIVEDIR/$SRC ] then wget "$LINK/$SRC" fi NAME=libmpc SRC=$NAME-$VERSION-mingw32-dll-2.tar.lzma echo "mingw mpc (Multi-Precision library for Complex numbers): " $SRC if [ ! -f $ARCHIVEDIR/$SRC ] then wget "$LINK/$SRC" fi NAME=mpfr VERSION=2.4.1-1 SRC=$NAME-$VERSION-$EXTLZMADEV LINK="http://www.mirrorservice.org/sites/download.sourceforge.net/pub/sourceforge/m/project/mi/mingw/MinGW mpfr/mpfr-2.4.1-1" echo "mingw mpfr (Multiple-Precision Floating-point computations with correct Rounding): " $SRC if [ ! -f $ARCHIVEDIR/$SRC ] then wget "$LINK/$SRC" fi NAME=libmpfr SRC=$NAME-$VERSION-mingw32-dll-1.tar.lzma echo "mingw mpfr (Multiple-Precision Floating-point computations with correct Rounding): " $SRC if [ ! -f $ARCHIVEDIR/$SRC ] then wget "$LINK/$SRC" fi NAME=gmp VERSION=5.0.1-1 SRC=$NAME-$VERSION-$EXTLZMADEV LINK="http://www.mirrorservice.org/sites/download.sourceforge.net/pub/sourceforge/m/project/mi/mingw/MinGW gmp/gmp-5.0.1-1" echo "mingw gmp (GNU Multiple Precision arithmetic library): " $SRC if [ ! -f $ARCHIVEDIR/$SRC ] then wget "$LINK/$SRC" fi NAME=libgmp SRC=$NAME-$VERSION-mingw32-dll-10.tar.lzma echo "mingw gmp (GNU Multiple Precision arithmetic library): " $SRC if [ ! -f $ARCHIVEDIR/$SRC ] then wget "$LINK/$SRC" fi NAME=pthreads-w32 VERSION=2.8.0-3 SRC=$NAME-$VERSION-$EXTLZMADEV LINK="http://www.mirrorservice.org/sites/download.sourceforge.net/pub/sourceforge/m/project/mi/mingw/MinGW pthreads-w32/pthreads-w32-2.8.0-3" echo "mingw pthreads (Posix THREADS): " $SRC if [ ! -f $ARCHIVEDIR/$SRC ] then wget "$LINK/$SRC" fi NAME=libpthread SRC=$NAME-$VERSION-mingw32-dll-2.tar.lzma echo "mingw pthreads (Posix THREADS): " $SRC if [ ! -f $ARCHIVEDIR/$SRC ] then wget "$LINK/$SRC" fi NAME=libgomp VERSION=4.5.0-1 SRC=$NAME-$VERSION-mingw32-dll-1.tar.lzma LINK="http://www.mirrorservice.org/sites/download.sourceforge.net/pub/sourceforge/m/project/mi/mingw/MinGW/BaseSystem/GCC/Version4/gcc-4.5.0-1/" echo "mingw gomp (GNU implementation of OpenMP - multi-platform shared-memory parallel programming): " $SRC if [ ! -f $ARCHIVEDIR/$SRC ] then wget "$LINK/$SRC" fi NAME=libssp SRC=$NAME-$VERSION-mingw32-dll-0.tar.lzma echo "mingw ssp (Stack Smashing Protection): " $SRC if [ ! -f $ARCHIVEDIR/$SRC ] then wget "$LINK/$SRC" fi NAME=gcc-core SRC=$NAME-$VERSION-$EXTLZMABIN echo "mingw gcc-core (gnu compiler): " $SRC if [ ! -f $ARCHIVEDIR/$SRC ] then wget "$LINK/$SRC" fi NAME=libgcc SRC=$NAME-$VERSION-mingw32-dll-1.tar.lzma echo "mingw libgcc (gnu compiler libraries): " $SRC if [ ! -f $ARCHIVEDIR/$SRC ] then wget "$LINK/$SRC" fi NAME=gcc-c++ SRC=$NAME-$VERSION-$EXTLZMABIN echo "mingw gcc-core (gnu C/C++ compiler): " $SRC if [ ! -f $ARCHIVEDIR/$SRC ] then wget "$LINK/$SRC" fi NAME=libstdc++ SRC=$NAME-$VERSION-mingw32-dll-6.tar.lzma echo "mingw libgcc (gnu C/C++ compiler libraries): " $SRC if [ ! -f $ARCHIVEDIR/$SRC ] then wget "$LINK/$SRC" fi
The mingw-get installer currently installs only GCC 3. You will get GCC 3 using this method. If you want to install the latest GCC release, use the Manual Installation method above.
If you are new to MinGW, the recommended way to begin is to:
- Download the mingw-get installer and extract 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.
- 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.
- 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).
- 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.
Instead of using an installer you can as well get all required packets and unpack them manually into a subdirectory. In fact that's what this writer is doing himself.
Download the Packages
At least the following (or newer) packages from the
- MinGW download page http://sourceforge.net/project/showfiles.php?group_id=2435
are needed (the automated mingw installer I think includes all of these and sets up the right directory for you--what it's doing is downloading compilers and default header files, and putting them in one place on your system, so the future builds will use those compilers and directories for building):
- GNU Binutils: http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=11290
- GCC Version 3: http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=82723
- MINGW Runtime: http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=11598
- Windows 32 API: http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=11550
Note that you will need gcc-core for other gcc language front ends to work properly.
These files are gzipped tarballs, Linux users will probably be familiar with .tar.gz files, but they are not that common under Windows. Essentially they are compressed folders like zip files. In order to access the contents you will need to decompress them, this requires that you have gzip and tar installed on your machine. Linux comes with these as standard in every distribution, but under Windows you will need to install them manually. Windows versions can be found at:
- Gzip for Windows: http://gnuwin32.sourceforge.net/packages/gzip.htm
- MinGW downloads section, MinGW standalone version of TAR (which also handles lzma and xz): http://www.mirrorservice.org/sites/download.sourceforge.net/pub/sourceforge/m/project/mi/mingw/MinGW%20Utilities/basic%20bsdtar/
- LibArchive for Windows, TAR: http://gnuwin32.sourceforge.net/packages/tar.htm.
If you see a file with the extension lzma or xz instead of tar, it uses a newer compression algorithm that makes use of lzma. It's become the standard for Slackware tarballs and many Linux distributions are starting to use xz because it offers better compression ratios than tar. To decompress a file with the lzma or the xz extension, you can use 7zip http://www.7-zip.org/. If you prefer the command line, there's a 7za program at the 7zip site. You can also check the mingw file archives for the xz program. It will decompess xz files or the files using the older lzma standard.
Download the setup files and install the applications. Before you use them you need to tell Windows where to find them; specifically this means adding the install directory to your PATH. To do this, follow the procedure below, to update the PATH appropriately, in your Environment Settings.
Create Install Directory
Caution: Never install MinGW into any directory which includes spaces in its absolute path name.
Create a directory to install all the stuff into. This writer usually creates C:\MinGW, (the recommended default), and copies all of the above files in there. Now issue the following commands, remember to change the file names to match your downloads:
cd /d c:\MinGW gzip -df binutils-2.19.1-mingw32-bin.tar.gz tar -xf binutils-2.19.1-mingw32-bin.tar cd info ren dir dir.binutils cd .. gzip -df gcc-core-3.4.5-20060117-3.tar.gz tar -xf gcc-core-3.4.5-20060117-3.tar cd info copy dir dir.gcc copy dir+dir.binutils cd .. gzip -df gcc-g++-3.4.5-20060117-3.tar.gz tar -xf gcc-g++-3.4.5-20060117-3.tar gzip -df mingwrt-3.15.2-mingw32-dev.tar.gz tar -xf mingwrt-3.15.2-mingw32-dev.tar gzip -df mingwrt-3.15.2-mingw32-dll.tar.gz tar -xf mingwrt-3.15.2-mingw32-dll.tar gzip -df w32api-3.13-mingw32-dev.tar.gz tar -xf w32api-3.3-mingw32-dev.tar
- If you wish to use other programming languages, in addition or instead of "C" and "C++", you should repeat the commands related to "gcc-g++", substituting the appropriate language package tarball; you must still install the "gcc-core" package.
- The indicated commands copying and concatenating the info/dir files are really a rather crude way of creating a combined documentation catalogue; they apply only if using older package versions than those indicated, since precompiled info/dir files are no longer distributed. In any case, this technique really isn't appropriate: see the comment below, for discussion on the purpose of, and the correct way to maintain, an info catalogue.
Additional Programming Languages
To add additional languages apply some or all of the following commands:
cd /d c:\MinGW tar xvzf gcc-ada-3.4.5-20060117-1.tar.gz tar xvzf gcc-g77-3.4.5-20060117-1.tar.gz tar xvzf gcc-java-3.4.5-20060117-1.tar.gz tar xvzf gcc-objc-3.4.5-20060117-1.tar.gz
You may also want to install MSYS.
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.
See also: Getting Started