QT应用程序与使用QT制造的DLL链接时崩溃
Qt app crashing on linking with DLL made using Qt
在询问问题之前,我想告诉我我已经在这里彻底搜索了答案。他们似乎都没有解决我的问题。问题:我已经在QT Wiki上给出的以下步骤创建了一个简单的C DLL文件。问题是创建了DLL,并且我将其链接到我的QT Widget应用程序,该应用程序在创建文件的对象时崩溃。在这里,我发布了源代码和QDebug输出
Libraray Qt Pro
QT += core gui widgets
TARGET = myLib
TEMPLATE = lib
DEFINES += MYLIB_LIBRARY
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES +=
mylib.cpp
HEADERS +=
mylib.h
mylib_global.h
unix {
target.path = /usr/lib
INSTALLS += target
}
mylib.h
#ifndef MYLIB_H
#define MYLIB_H
#include "mylib_global.h"
class MYLIBSHARED_EXPORT MyLib
{
public:
MyLib();
int add(int x, int y);
int sub(int x, int y);
};
#endif // MYLIB_H
mylib_global.h
#ifndef MYLIB_GLOBAL_H
#define MYLIB_GLOBAL_H
#include <QtCore/qglobal.h>
#if defined(MYLIB_LIBRARY)
# define MYLIBSHARED_EXPORT Q_DECL_EXPORT
#else
# define MYLIBSHARED_EXPORT Q_DECL_IMPORT
#endif
#endif // MYLIB_GLOBAL_H
mylib.cpp
#include "mylib.h"
#include<QDebug>
MyLib::MyLib()
{
}
int MyLib::add(int x, int y)
{
qDebug()<<"Adding";
return x+y;
}
int MyLib::sub(int x, int y)
{
return x-y;
}
现在应用
mywidgetApp.pro
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = myWidgetApp
TEMPLATE = app
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES +=
main.cpp
mainwindow.cpp
HEADERS +=
mainwindow.h
FORMS +=
mainwindow.ui
INCLUDEPATH += "D:GurushantMy Other Side ProjectsMaking dll FilesmyLib"
LIBS += "D:GurushantMy Other Side ProjectsMaking dll Filesbuild-myLib-Desktop_Qt_5_9_1_MinGW_32bit-ReleasereleasemyLib.dll"
mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include"mylib.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
MyLib lib;
lib.add(1,2);
}
MainWindow::~MainWindow()
{
delete ui;
}
现在的应用程序输出 D:GurushantMy Other Side ProjectsMaking dll Filesbuild-myWidgetApp-Desktop_Qt_5_9_1_MinGW_32bit-ReleasereleasemyWidgetApp.exe
崩溃了。
我正在使用QT 5.9.1
在进行大量反复试验之后,包括库的最佳方法是
INCLUDEPATH += (Your_Path)
DEPENDPATH += (Your Path)
(if your target path is win32)
win32:CONFIG(release, debug|release): LIBS += -L(path) -l(lib_file_without_dot_dll)
- 在-l 之后不要使用空间
相关文章:
- 无法使用 Qt 15.3.1 进行远程调试时加载 qtcreatorcdbext.dll
- Qt应用程序找不到第三方DLL并崩溃
- 应用程序仅在qt调试器中加载dll,而不是独立加载
- QT 加载.dll不调用解析
- 在Visual Studio中调试Qt,缺少msvcp140d_app.dll
- 指定Qt查找OpenSSL DLL的位置
- 为什么 Python 需要 DLL 中的 GetMessage 消息泵送,而不是 Qt
- 在Visual Studio 2017中使用Qt库的CMake项目:运行exe时找不到Qt dll
- 是否可以在QT中使用C#DLL
- MFC App中的QT DLL-如何使Qdialog *真正 *模式
- 从Qt(c ++)调用DLL中的函数
- 将 pthreadgc2.dll 连接到 qt 项目
- QT 创建器:无法添加 OpenCV dll 库 ( "File format not recognized" )
- 部署Qt-dll文件-找不到windows插件,尽管平台/qwindows.dll存在,因此存在libEGL和libGL
- 将非托管"QT" dll 导入 C# 给出 dllNotFoundException 但存在
- 如何使用基于 Qt 的依赖项组织 Qt DLL
- 使用来自非Qt DLL(JNA)的QTimer
- 编译器之间的 Qt DLL 兼容性
- 将Qt DLL保存在单独的文件夹中
- Qt-Dll相关问题