Home > Software design >  QApplication Crashing on Constructor call
QApplication Crashing on Constructor call

Time:10-08

I have a very basic QT application. Using QT 5.9.1.

At the very first line in my main method:

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

My call to the QApplication constructor crashes.

I've tried to launch this in a gdb debugger within VS Code, however because I don't have 'QApplication.cpp', I can't step through the constructor call. I can't really find any other backtrace information. If I just launch GDB in the terminal, I can't get the application to see Windows platform DLLs

Is there any otherway to debug this? I can't see why this is happening, but I am out of ideas... i

CodePudding user response:

You might have a plugin problem, or other installation issue. Define this environment variable at runtime (in the terminal).

$ QT_DEBUG_PLUGINS=1 ./myapp

If this doesn't provide anything useful, you might try running your application under strace, so you can see which files it is attempting to access, and if there is any suspicious system call that provides a hint:

$ strace ./myapp

CodePudding user response:

This same code works for me.

Could I suggest you to try a complete minimal example?

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

If this does not work, reinstalling the Qt library seem the most obvious way to troubleshot. Maybe some missmatch between headers and/or libs.

  • Related