qt - QApplication段错误

标签 qt segmentation-fault qt4.8

尝试创建 QApplication 时发生崩溃目的。这是我的代码:

#include <QLabel>
#include <QApplication>

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

我使用的是 Qt 4.8.4 版和 MinGW 编译器。我的应用程序在运行时崩溃 QCoreApplicationPrivate::processCommandLineArguments方法。谁能告诉如何解决这个问题?

最佳答案

显然,这个错误是由 Qt 二进制文件和你的编译器的二进制不兼容引起的。

来自 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.



如果您使用的是 gcc 4.7(我认为这是最新 MinGW 的默认版本),则无法使用 Qt 4 预编译二进制文件进行编译(好吧,您可以,但是 it will not work )。

因此,要么将 gcc 降级到 4.4 版本,要么将 Qt 升级到最新(Qt 5)版本。

关于qt - QApplication段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14685425/

相关文章:

c++ - 为什么从线程执行方法时使用 QMetaObject::invokeMethod

c++ - 处理迭代器时由信号 SIGSEGV(地址边界错误)终止

macos - sudo 命令后出现段错误

linux - 获取关于段错误或崩溃的指令指针(针对 x86 JIT 编译器项目)?

c++ - 从字母数字 QString 中提取数字

c++ - 如何在 OpenSuse 上的 Qt 中访问 Awesomefonts

qt - 使用高速互联网连接时降低 readRead() 的 cpu 成本

c++ - QString 的隐式共享实现如何线程安全?

python - 循环中槽位连接少

qt - QAudioInput::byteReady() 和 QIODevice::read() 给出不同的字节数