Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt Creator error code -1073741819

Ok, so have Qt Creator and I tried creating just the most basic application, under Projects->Applications->Qt Gui Applications. The project was successfully created. Furthermore, when I compiled it, it appeared to work just fine.

11:07:38: Running steps for project Test1...
11:07:38: Configuration unchanged, skipping qmake step.
11:07:38: Starting: "C:\MinGW\bin\mingw32-make.exe" 
C:/MinGW/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory 'C:/Users/User/CProjects/Test1-build-Windows7Desktop-Debug'
mingw32-make[1]: Nothing to be done for 'first'.
mingw32-make[1]: Leaving directory 'C:/Users/User/CProjects/Test1-build-Windows7Desktop-Debug'
11:07:39: The process "C:\MinGW\bin\mingw32-make.exe" exited normally.

However, when I attempt to run it, I get this:

Starting C:\Users\User\CProjects\Test1-build-Windows7Desktop-Debug\debug\Test1.exe...
The program has unexpectedly finished.
C:\Users\Hunter\User\Test1-build-Windows7Desktop-Debug\debug\Test1.exe exited with code -1073741819

Every time. I start a new project, I do whatever, but I get that error. Now, I have also run in debug mode. I get this error:

The inferior stopped because it received a signal from the Operating System.
Signal name: SIGSEGV
Signal meaning: Segmentation fault

The offending file is qatomici386.h at line 132, and the specific function is QBasicAtomicInt::deref which states:

inline bool QBasicAtomicInt::deref()
{
        unsigned char ret;
    asm volatile("lock\n"
                 "decl %0\n"
                 "setne %1"
                 : "=m" (_q_value), "=qm" (ret)
                 : "m" (_q_value)
    -->          : "memory");
    return ret != 0;
}

I have arrowed line 132. I am running a 64 bit machine, but I believe I installed a 32 bit MinGW... but honestly I don't even know if that is the real problem, let alone how to fix it if it is. I am very new to C++ and Qt.

As requested, here is my code: mainwindow.cpp:

#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}

main.cpp:

#include "mainwindow.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    return a.exec();
}

Test1.pro:

#-------------------------------------------------
#
# Project created by QtCreator 2012-12-17T23:06:31
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = Test1
TEMPLATE = app


SOURCES += main.cpp\
        mainwindow.cpp

HEADERS  += mainwindow.h

FORMS    += mainwindow.ui

mainwindow.h

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private:
    Ui::MainWindow *ui;
};

#endif // MAINWINDOW_H

If anything else is needed, just ask.

Here is the complete debugging backtrace:

0   QBasicAtomicInt::deref  qatomic_i386.h  132 0x402774    
1   QString::~QString   qstring.h   880 0x402805    
2   WinMain@16  qtmain_win.cpp  93  0x401eab    
3   main            0x402e6b    

Update: I ran the example toy clock, and it worked fine. However, when I ran the calculator form, it resulted in the exact same error. I notice that the calculator form is in the normal project form: it has a .pro, and Header, Sources, and Forms folders. The toy clock on the other hand just has a .qmlproject file and a qml folder. It also fails at the same location with the same backtrace. I don't actually know much about any of these things, but hopefully it will help find a solution.

like image 411
MirroredFate Avatar asked Oct 05 '22 15:10

MirroredFate


2 Answers

I've been having the same problem, after just installing this whole environment.

I have been searching around, and there appears to be a bug on the Qt bug tracker at: https://bugreports.qt.io/browse/QTCREATORBUG-7653

From the page:

There are multile binary incompatible versions of mingw. You need to use the same[1] mingw >version for both qt and your program. Which means either compiling qt yourself with that >mingw version or using the same as what was used for compiling the binary qt packages.(I'm not sure but that might be a newer than ftp://ftp.qt.nokia.com/misc/MinGW-gcc440_1.zip )

[1] same in the sense of ABI

like image 125
Favil Orbedios Avatar answered Oct 12 '22 09:10

Favil Orbedios


Comparing some of my (inherited) Qt apps and this Qt tutorial, I notice a difference in the initializer for MainWindow. It may just be a convention, but these sources show MainWindow directly inheriting the Ui class, and then a direct call to setupUi(this);.

So, this would retool your mainwindow.cpp to:

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent)
{
    setupUi(this);
}

You didn't include mainwindow.h, but the class definition should look like:

class MainWindow : public QMainWindow, private Ui::MainWindow
{
//...
like image 30
em.eh.kay Avatar answered Oct 12 '22 11:10

em.eh.kay