I’ve downloaded Qt 4.8.2 library, Qt Creator 2.5.2, and manually installed MingW with w32api version 3.13 and GCC/g++ version 4.7.0.1. My OS is Windows 7 Ultimate x64.
I can create a sample “Plain C++ project” in Qt Creator; compile and run that console application using g++ without any issue.
But I cannot run a Qt application. I used Qt Creator, created a dummy Qt Application using Creator’s “Qt Gui Application” template. The project can be compiled successfully, without any error or warning. But the binary keeps crashing when I try to run (both from Qt Creator and Windows Explorer) it. Both debug and release builds crash. It crashes even before showing main window.
MingW is installed in C:\MingW and C:\MingW\bin is in PATH. Qt is installed in C:\Qt\4.8.2 and C:\Qt\4.8.2\bin is in PATH.
I analyzed generated exe of the Qt Gui Application output with Dependency Walker and found that it found all required DLLs:
- c:\windows\system32\KERNEL32.DLL
- c:\windows\system32\MSVCRT.DLL
- c:\mingw\bin\LIBGCC_S_DW2-1.DLL
- c:\mingw\bin\LIBSTDC++-6.DLL
- c:\qt\4.8.2\bin\QTCORE4.DLL
- c:\qt\4.8.2\bin\QTGUI4.DLL
So, what’s causing the runtime crash?
EDIT
I also tried Qt’s example projects: 2dpainting and addressbook – both crashed when they were launched.
You should build Qt with the MinGW compiler you’re using to build your application. GCC is generally less sensitive to binary compatibility issues than MSVC is, but Qt is a big, complex framework library. If anything would expose those kinds of issues, Qt would probably be on the short list.
Building Qt is pretty straightforward, but it takes a lot of time and there always seems to be two or three patches I need to make to get things to build successfully.
The last time I built Qt (4.7.3) with MinGW, I had to make the following patches – I’m not sure whether they will still apply to Qt 4.8:
there is a problem with how some distributions of MinGW incorporate the Microsoft extensions to
float.h– I had to sometimes had to add the line:to the end of the MinGW-specific
float.hso the generic GCCfloat.hwould get processed properly. I had to do this for nuwen 4.7.0lib/gcc/i686-pc-mingw32/4.7.0/include/float.hand TDM 4.6.1 32-bit distrolib/gcc/mingw32/4.6.1/include/float.h(the 64-bit distro of TDM didn’t need this patch).patch
qmake\Makefile.win32-g++andqmake\Makefile.win32-g++-shto remove the-static-libstdc++option that GCC doesn’t recognize (and now errors out on instead of ignores)patch
mkspecs/win32-g++/qmake.confto move the-Wl,in theQMAKE_LFLAGS_EXCEPTIONS_ONmacro to its proper place inQMAKE_FLAGS:copy
make.exetomingw32-make.exein MinGW’sbindirectory if there’s not already amingw32-make.exeThen building Qt consists of:
This takes a while… hopefully nothing else will need patching.