Download and install MinGW:
1. download MinGW-5.1.4.exe, create c:\MinGW, and run it. It’ll download and install the current stable version of GCC, G++ etc.
2. set the environment, add c:\MinGW\bin;C:\MinGW\libexec\gcc\mingw32\3.4.5 to PATH
2.1 download gdb and extract to c:\MinGW
2.2 start a console, make sure you can run gcc -v and gdb -v
3. download code::blocks 8.02, install and start it
3.1 in code::blocks, settings->Global compiler settings, selected compiler=GNU GCC Compiler, then add the following into Search directories
Compiler tab
C:\MinGW\include
C:\MinGW\include\c++\3.4.5
C:\MinGW\include\c++\3.4.5\backward
C:\MinGW\include\c++\3.4.5\mingw32
C:\MinGW\lib\gcc\mingw32\3.4.5\include
Linker tab
C:\MinGW\lib
C:\MinGW\lib\gcc\mingw32\3.4.5
Resource compiler tab
C:\MinGW\include
Note if your GCC is not 3.4.5, please change to the correct version.


Now the most important part: START THE PROJECT in C: , don’t in D:, if you start the project in other disk, you’ll get the following error when you compile a standard C project:
ld: crt2.o: No such file: No such file or directory
I don’t know the reason, but if you copy crt2.o, crtbegin.o and crtend.o to the project directory, it’ll be able to show you another issue:
undefined reference to `WinMain@16′
If the project located at c:\somedir, the those issues will disappear. What a strange thing!