Code::Blocks Pre-build options inconsistent with command line (Qt)-Collection of common programming errors

I am trying to compile a simple Qt program with Code::Blocks. I am using Qt’s build system, so instead of Code::Blocks compiling it, I have Code::Blocks’ build target type set to “Commands only” and I am using the pre/post build steps options. The contents of my “Pre-build steps” are as follows:

qmake.exe GUI.pro
C:/QtSDK/mingw/bin/mingw32-make.exe -f Makefile.Debug

When I compile within Code::Blocks, I get these errors:

c:\QtSDK\Desktop\Qt\4.8.1\mingw\lib/libqtmaind.a(qtmain_win.o): In function `WinMain@16':
c:\iwmake\build_mingw_opensource\src\winmain/qtmain_win.cpp:93: undefined reference to `_Unwind_Resume'
c:\iwmake\build_mingw_opensource\src\winmain/qtmain_win.cpp:135: undefined reference to `_Unwind_Resume'
c:\QtSDK\Desktop\Qt\4.8.1\mingw\lib/libqtmaind.a(qtmain_win.o):c:\iwmake\build_mingw_opensource\src\winmain/../../include/QtCore/../../src/corelib/tools/qvector.h:512: undefined reference to `_Unwind_Resume'
c:\QtSDK\Desktop\Qt\4.8.1\mingw\lib/libqtmaind.a(qtmain_win.o):c:\iwmake\build_mingw_opensource\src\winmain/../../include/QtCore/../../src/corelib/tools/qvector.h:513: undefined reference to `_Unwind_Resume'
c:\QtSDK\Desktop\Qt\4.8.1\mingw\lib/libqtmaind.a(qtmain_win.o):qtmain_win.cpp:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
mingw32-make.exe: *** [debug\GUI.exe] Error 1

However, the strange thing is, when I enter the two commands above using Windows command line, it works fine. It successfully builds a .exe that works and shows a simple window.

Both Code::Blocks and command line’s build logs are exactly the same (I checked), except for Code::Blocks’ errors.

It seems like qmake and the makefile don’t have anything to do with this, or at least the above happens when the makefiles don’t change.

I have made sure to delete the .o and .exe files in Debug every time I compile.

Both Code::Blocks and cmd output the same 4 files (3 .o files and 1 .cpp file), except for cmd’s .exe. However, I noticed that one file is 262kb when compiled with Code::Blocks, and 263kb when compiled via command line.

In Pre-build steps, I’ve tried calling cmd with the commands, and I’ve tried calling a batch file, but the same errors come up.