Just had a problem with this and I believe I fixed it; here's what I did, let me know if it helps you:
I fixed it; what I did was I went to settings>compiler and debugger
selected the toolchain executables tab
By default (from a fresh install) the version available right now has the default folder for MinGW WRONG. It has C:/MinGW, but the actual folder where it's installed to is C:\Program Files\CodeBlocks\MinGW (for windows). I just did an auto-detect and it corrected the problem, and voila; I can now build and run.
Directories may be different, but basically go to settings>compiler and debugger and select the toolchain executables tab, and press the auto-detect button for the MinGW directory. Let me know if this corrects your problem.