Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt/Qt Creator - The program has unexpectedly finished. <program's path> crashed

Tags:

c++

qt

qt-creator

I'm somewhat new to C++ and to Qt 5.2.1. I'm actually learning how to use Qt. To do it as easy as possible, I'm using Qt Creator 3.0.1.

I've written this little piece of code in the main.cpp file of my project :

#include <QApplication>
#include <QPushButton>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QPushButton bouton("Hello !");
    bouton.show();

    return app.exec();

}

And the .pro file (by default) :

SOURCES += \
    main.cpp

I tried to make it run, then I got the issue "QApplication : no such file or directory".

Then, I added "QT += widgets" to the .pro file (full file) :

SOURCES += \
    main.cpp
QT += widgets

And now I get :

Starting <path to .exe>... 
The program has unexpectedly finished.
<path to .exe> crashed

Please, tell me how to make it work. Thanks for reading and for your help.

(OS : Windows 7, Debug : Desktop Qt 5.2.1 MinGW 32bit)

Compile Output :

16:06:54: Running steps for project test...
16:06:54: Configuration unchanged, skipping qmake step.
16:06:54: Starting: "C:\Qt\Tools\mingw48_32\bin\mingw32-make.exe" 
C:/Qt/Tools/mingw48_32/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory 'C:/Users/PLD/Documents/PLD/Projets Codages/Qt/Qt/build-test-Desktop_Qt_5_2_1_MinGW_32bit-Debug'
mingw32-make[1]: Nothing to be done for 'first'.
mingw32-make[1]: Leaving directory 'C:/Users/PLD/Documents/PLD/Projets Codages/Qt/Qt/build-test-Desktop_Qt_5_2_1_MinGW_32bit-Debug'
16:06:55: The process "C:\Qt\Tools\mingw48_32\bin\mingw32-make.exe" exited normally.
16:06:55: Elapsed time: 00:01.

Application Output :

Starting C:\Users\PLD\Documents\PLD\Projets Codages\Qt\Qt\build-test-Desktop_Qt_5_2_1_MinGW_32bit-Debug\debug\test.exe...
The program has unexpectedly finished.
C:\Users\PLD\Documents\PLD\Projets Codages\Qt\Qt\build-test-Desktop_Qt_5_2_1_MinGW_32bit-Debug\debug\test.exe crashed
like image 594
PLD Avatar asked Nov 11 '22 13:11

PLD


1 Answers

The code looks good. One explanation for what you get would be incompatible DLLs (e.g. Debug vs Release builds, or MSVC vs MinGW). You could start depends.exe with your .exe and check whether it picks up libraries from unexpected locations.

like image 85
Aguest Avatar answered Nov 15 '22 07:11

Aguest