Static release app crashes, all others are fine

  • I am using Qt 5.7 / Creator 4.1 on Windows with Mingw. I built a static build of Qt from source per these instructions:

    The only difference is I downloaded the source ( manually instead of downloading it via the Qt Maintenance Tool. I added it as a new kit.

    Any app I build as 'static release' crashes upon signal emission from widgets. Any test app I try works fine when built 'static debug', 'dynamic release', or 'dynamic debug'.

    For example, a new bare Qt Widgets Application with only a MainWindow will run as static release but will crash if I move the empty toolbar. If I add a pushbutton widget, then it will crash if I click the button. If I add a LineEdit, then it will crash when I hover over the edit box. If I add a TextEdit, it crashes on launch. In all of these cases, it still crashes even if I connect the signals to a slot. In the case of the TextEdit, I connected every signal, including inherited signals, to a slot but it still crashes:

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <iostream>
    MainWindow::MainWindow(QWidget *parent) :
        ui(new Ui::MainWindow)
        connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(nothing()));
        connect(ui->textEdit, SIGNAL(selectionChanged()), this, SLOT(nothing()));
        connect(ui->textEdit, SIGNAL(textChanged()), this, SLOT(nothing()));
        connect(ui->textEdit, SIGNAL(cursorPositionChanged()), this, SLOT(nothing()));
        connect(ui->textEdit, SIGNAL(copyAvailable(bool)), this, SLOT(nothing()));
        connect(ui->textEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(nothing()));
        connect(ui->textEdit, SIGNAL(redoAvailable(bool)), this, SLOT(nothing()));
        connect(ui->textEdit, SIGNAL(undoAvailable(bool)), this, SLOT(nothing()));
        connect(ui->textEdit, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(nothing()));
        connect(ui->textEdit, SIGNAL(windowIconChanged(QIcon)), this, SLOT(nothing()));
        connect(ui->textEdit, SIGNAL(windowTitleChanged(QString)), this, SLOT(nothing()));
        connect(ui->textEdit, SIGNAL(destroyed(QObject*)), this, SLOT(nothing()));
        connect(ui->textEdit, SIGNAL(objectNameChanged(QString)), this, SLOT(nothing()));
        delete ui;
        std::cerr << "Nothing to do here" << std::endl;

  • Lifetime Qt Champion

    Random luck strikes and I actually used the same tut to create
    a static kit on windows (10).

    I tried your sample but it dont crash at all.

    So maybe your build have some issue. Not sure what it could be.

    You could try run my compiled exe and see if it does crash on your system.
    (note. i dont normally advise running other unknown exe files but in this case it's 100% safe)

  • Moderators

    Try building the application as release with debug info: -O2 -g and attach gdb to the process before doing anything with the GUI. Hopefully this will allow you to extract a meaningful stack trace.

    Kind regards.

  • I deleted my entire source tree and source zip file and started all over from scratch. This time everything works, and I can create static builds of both release and debug for Windows. Yay!

  • Lifetime Qt Champion

    Thank you for reporting back.
    Can i as how big your static version is?
    (whole folder)

  • The entire Qt directory (installed version, Qt Creator, gcc, static build, etc) is 7.7GB

    Qt/Qt5_static is 3.5GB

     MINGW64 /d
    $ du -h --max-depth=1 Qt
    3.0G    Qt/5.7
    4.0K    Qt/dist
    448M    Qt/Docs
    92M     Qt/Examples
    184K    Qt/Licenses
    3.5G    Qt/Qt5_static
    662M    Qt/Tools
    6.3M    Qt/vcredist
    7.7G    Qt

  • Lifetime Qt Champion

    Thx. Just checking. Mine static qt folder was ca. the same
    and i was wondering if i made it fat somehow ;)
    but seems pretty normal size. thank you.

Log in to reply