QApplication segmentation fault

风格不统一 提交于 2019-12-07 07:56:55

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/14685425/qapplication-segmentation-fault

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!