Пустой QT GUI вылетает после связывания DLL - PullRequest
0 голосов
/ 11 апреля 2020

Для моего проекта мне нужна GUI и библиотека под названием «STM32CubeProgrammer CLI». Они включают несколько примеров проектов C ++ с VS и QT (оба - только командная строка, без GUI). Я могу скомпилировать и работать с ними.

На следующем шаге я создал приложение виджетов QT и добавил библиотеку STM, но программа мгновенно создала sh.

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11

# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
    main.cpp \
    mainwindow.cpp

HEADERS += \
    mainwindow.h
    $$PWD/../../../include/CubeProgrammer_API.h \
    $$PWD/../../../include/DeviceDataStructure.h \

FORMS += \
    mainwindow.ui


#comment out that line and the programm works
win32: LIBS += -L$$PWD/../../../lib/ -lCubeProgrammer_API

INCLUDEPATH += $$PWD/../../../include
DEPENDPATH += $$PWD/../../../include

Это основной. cpp Я не редактирую никакие "окна" или другие файлы, я даже не использую функцию dll.

#include "mainwindow.h"

#include <QApplication>

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

Компоновщик находит dll, но программа вылетает, только если я использую GUI, простая программа cmd не делает sh. Ради интереса я добавил Qlibrary, но программа вылетает до.

Я использую qmake, QT 5.14.2 MinGW-32bit и QT Creator 4.11.1.

...