Building GCC on Windows

Instructions for a native bootstrap of GCC on Windows for i386-pc-mingw32.

These instructions will be merged into the GCC documentation when they become more mature.

Required Prerequisites

MinGW toolchain

You must have the MinGW toolchain installed to build GCC. The toolchain is composed of two parts, the host libraries and tools, and the host compiler. A complete toolchain which satisfies the requirements below can be installed using the installer from

These notes only discuss MinGW-specific prerequisite issues. Please see for a complete list of prerequisites.

mingw-runtime (version 3.12 or higher): This is the equivalent of libc on Unix which provides an interface to Microsoft's C runtime that is shipped with Windows.

Host Tools and Libraries

Host Compiler

Host Tools

MSYS: MSYS is an environment available at <> that is designed to work with MinGW, and it should work seamlessly. MSYS is a stripped-down and specialized fork of Cygwin. Unfortunately, in the past, MSYS has suffered from various bugs that have made building GCC difficult.

Cygwin: The Cygwin environment available at can provide the host tools. An advantage of using Cygwin is that it comes with almost all of the tools needed for developing and testing GCC. If Cygwin is used, two modifications must be made:

exec cp -p `echo $* | sed -r 's/(^| )-[^ ]*//g'`

UnxUtils: UnxUtils from can provide the set of tools needed. Some manual adjustment will be necessary to get this to work correctly.

Optional Prerequisites


All prerequisite tools should be in the PATH environment variable.

The console emulation in Cygwin and MSYS has a known problem that causes it to lose some output information from GCC, which can cause build failures to be rather mysterious. RXVT, for example, has this problem. For this reason, the Microsoft console should be used. Alternately, a console emulator that does not have this problem can be used, such as Console 2 from

Sometimes CRLF issues are a problem. Cygwin bash has a feature that can mitigate some of these problems, which can be activated in the following way: set -o igncr export SHELLOPTS

Including \r in the IFS environment variable may also be helpful in avoiding these problems.


Please see the GCC installation instructions for complete details.

GCC must be configured using a relative path.

Building MinGW is typically quite slow, apparently due to slow Makefile and shell script execution. Using multiple processors with make -jN can substantially speed up the process.

To enable all languages and all directories (except mudflap), a command similar to the following example can be used. Note that you will need to specify your own paths to configure, libiconv, gmp, and mpfr.

../gccsrc/configure --enable-languages=c,ada,c++,fortran,java,objc,obj-c++ --disable-sjlj-exceptions --enable-libgcj --enable-libgomp --with-dwarf2 --disable-win32-registry --enable-libstdcxx-debug --enable-concept-checks --enable-version-specific-runtime-libs --prefix=/mingw --with-gmp=/mingw/src/gcc/gmp-mpfr-root --with-mpfr=/mingw/src/gcc/gmp-mpfr-root --with-libiconv-prefix=/mingw/src/gcc/libiconv-root


The DESTDIR variable can be used to control the output path.


make DESTDIR=/mingw/src/mytest/root install

None: WindowsBuilding (last edited 2008-06-03 20:12:58 by AaronLaFramboise)