QApplication分段错误 [英] QApplication segmentation fault

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

问题描述

尝试创建 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的默认版本),你不能编译(嗯,你可以,但是它不会工作) 与 Qt 4 预编译的二进制文件.

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.

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

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