I see it's an old topic, but today I had the same problem with code::blocks 8.02 mingw.
I did not see here the exact answer, so I wish to write it.
It's very simple. The problem is with the path. go to: settings/compiler and debugger/Toolchain executables
Select the Compiler's intallation direectory properly. Like ...\CodeBlocks\MinGW