How to Install gcc/g++ 4.7.2 on CygwinThe recent Cygwin distribution (1.7.17-x) provides only
an outdated Gnu
compiler version. The latest version is gcc/g++ 4.5.3-3 from the devel/gcc4-core package. If you
need better C++11 standard
complience you will have to install a newer gcc version right from the
sources. This is easier than it may sound. The following report describes how gcc/g++ 4.7.2 can be installed on a
Cygwin system.

Users of tcsh shell have
to use the appropriate syntax to set the variables. Additionally, the
system PATH variable
needs some extensions. Add the string

/usr/local/bin;/usr/bin;/bin;/usr/sbin;

before the entry /windows/system32.
This is necessary, because otherwise Windows commands with the same
names
would be executed instead of the corresponding Unix shell
commands. You will easily find the dialog for setting environment
variables in Windows 7 by right clicking the "Computer icon" on the
desk top, choosing "Properties", selecting "Advanced system settings"
in the left pane, selecting the "Advanced Tab", clicking on the
"Environment Variables" button, choosing the lower pane with "System
variables", and finally pressing the "Edit..." button. Now you can modify the PATH string. Reboot the
computer before proceeding. You can check that the variables are set
correctly by entering the shell commands

Build the Compiler

Create a new build directory /usr/local/contrib and move all source packages into this directory. Then move into this directory by

cd /usr/local/contrib

The make tool has the
ability to execute independent jobs in parallel. On a multi-core
machine this can significantly speed up the build process. The option

make -j N

generates upto N parallel threads. On a quad-core machine the value N = 4 is a good choice.

The building blocks of the compiler must be assembled exactly in the
order given below. You should be patient. Especially the 4th step takes
quite a long time. The whole build process can take 2 to 4 hours (of
course depeding on the compute power of your machine).

4. Build gcc (Here: version: 4.7.2)

Currently, the self-check of the gcc is not working, so this step is omitted here.
Now you should check that the new compiler version 4.7.2 is called
instead of the compiler used for the build process (here gcc-4.5.3).
Enter the following commands:

gcc --version; g++ --version

The new compiler has been installed in /usr/local/bin. It is now the default compiler, because in the PATH variable /usr/local/bin is before /usr/bin.