I'm doing that every day and it works just fine, so there is no inherent problem regarding that in either Code::Blocks or MinGW.
Before trying to get C++ with OpenGL to work, have you tried compiling something C++ alone (with no OpenGL)? Because if that doesn't work either, then most likely you have incorrectly configured gcc instead of g++ in your toolchain executables.