I encountered the same problem and solved it after a bit of tinkering...
steps would be:
1. goto "Menu"->Settings ->"Compiler and Debugger" -> [It will open a new Tab ]..... ->
2. In this tab, you have listings like...Compiler flags, Linker settings, Search subdirectories,...... next to that is ">" button, click on the ">" button 2-3 times, till you find "Toolchain executables" in same line.
3. In this window, set "compiler settings" to which ever directories your compiler is installed.
4. For varification, goto lower section of tab-menu and click on location button for gcc or g++, it shoulddirectly open a new browser window and gcc /g++ is selected.
<If this is done, your code::blocks should be working>