4

I get a crash when try to create a QApplication object. This is my code:

#include <QLabel>
#include <QApplication>

int main(int argc, char* argv[])
{
    QApplication app(argc, argv);
    return app.exec();
}

I am using Qt version 4.8.4 and the MinGW compiler. My application crashes when running QCoreApplicationPrivate::processCommandLineArguments method. Can anybody tell how to solve this problem?

Daniel Hedberg
  • 5,677
  • 4
  • 36
  • 61
Mikhail Zimka
  • 694
  • 1
  • 9
  • 20
  • Are you giving it any particular command line arguments that cause a problem, or does it always happen? – tmpearce Feb 04 '13 at 11:52
  • 1
    No, I am not. This problem takes place whenever I executing my application. Nemanja Boric was absolutely right, it is because Qt library version and mingw gcc version doesn't match. I solve this problem compiling Qt library by my own, as it is quite difficult to find an outdated version of mingw. – Mikhail Zimka Feb 07 '13 at 03:39
  • @Zimka: Yes there is chaos with mingw version numbering. Currently I am testing third version of it having the problem you described (beside others). – truthseeker Mar 28 '13 at 18:00

1 Answers1

6

Apparently, this error is caused by binary incompatibility of Qt binaries and your compiler.

From here:

There are binary installers targetting MinGW for both Qt 4 and Qt 5. The Qt 4 ones are built with aMinGW.org toolchain using gcc 4.4. The Qt 5 ones are based on a MinGW-builds toolchain [sourceforge.net] using gcc 4.7.2. The Qt 5 installer also ships the toolchain itself.

If you are using gcc 4.7 (I think this is the default version with the latest MinGW), you can't compile (well, you can, but it will not work) with Qt 4 precompiled binaries.

So, either downgrade your gcc to 4.4 version, or upgrade Qt to latest (Qt 5) version.

Nemanja Boric
  • 21,627
  • 6
  • 67
  • 91