Q应用程序分割错误 [英] QApplication segmentation fault

查看:121
本文介绍了Q应用程序分割错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试创建QApplication对象时出现崩溃.这是我的代码:

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();
}

我正在使用Qt版本4.8.4和MinGW编译器.运行QCoreApplicationPrivate::processCommandLineArguments方法时,我的应用程序崩溃.有人可以告诉您如何解决这个问题吗?

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?

推荐答案

显然,此错误是由Qt二进制文件与您的编译器的二进制不兼容引起的.

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

此处:

有一些针对Qt 4和Qt 5的MinGW的二进制安装程序. Qt 4是使用gcc 4.4使用aMinGW.org工具链构建的.这 Qt 5是基于MinGW构建的工具链[sourceforge.net] 使用gcc 4.7.2. Qt 5安装程序还附带了工具链本身.

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.

如果您使用的是gcc 4.7(我认为这是具有最新MinGW的默认版本),则无法编译(嗯,可以,但是

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.

因此,您可以将gcc降级到4.4版本,或者将Qt升级到最新(Qt 5)版本.

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

这篇关于Q应用程序分割错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆