当前位置:网站首页>QT QT 】 【 to have developed a good program for packaging into a dynamic library
QT QT 】 【 to have developed a good program for packaging into a dynamic library
2022-08-03 16:06:00 【Cappuccino-jay】
前两篇博客:
1、不带uiThe generation and invocation of the dynamic library of the interface
2、带uiThe generation and invocation of the dynamic library of the interface
If it is has developed a good project or a project,Want to encapsulate as a dynamic library,How to be faster and more convenient:
例如:QT项目工程
How to the project engineering fast packaging into dynamic library?
1、修改配置文件
#TEMPLATE = app
TEMPLATE = lib
DEFINES += RECDATA_LIBRARY

2、新建一个头文件recdata_global.h,并添加如下代码
#include <QtCore/qglobal.h>
#if defined(RECDATA_LIBRARY)
# define RECDATASHARED_EXPORT Q_DECL_EXPORT
#else
# define RECDATASHARED_EXPORT Q_DECL_IMPORT
#endif

3、引入头文件,Modify the derived class definition
#include "recdata_global.h"
class RECDATASHARED_EXPORT RecData : public QWidget

#include "recdata_global.h"
class RECDATASHARED_EXPORT showData : public QWidget

4、重新构建、运行
5、若是 MinGW32 编译器,After compiling, it will be found in the folder ***.dll 和 ***.a 文件;若是 MSVC 编译器,则应该是 ***.dll和 ***.lib .

6、调用
in programs that use the library,新建一个 include 文件夹 和 一个lib 文件夹,将 导出类的头文件 复制进include文件夹中,将编译生成的***.lib文件复制到lib文件夹中,Then import the header file into the program.
INCLUDEPATH += $$PWD/include
LIBS += -L$$PWD/lib -lRecData
在编译之后,Compile in different modesdllThe file is placed in the folder where the program is compiled,to run the program normally.
边栏推荐
猜你喜欢

土耳其国防部:联合协调中心将对首艘乌克兰粮船进行安全检查

Ark server opening tutorial win
How Navicat connects to MySQL on a remote server

Not to be ignored!Features and advantages of outdoor LED display

身为售后工程师的我还是觉得软件测试香,转行成功定薪11.5K,特来分享下经验。

语音识别新一轮竞争打响,自然对话会是下一个制高点吗?

Research on power flow in DC microgrid based on Newton's method (Matlab code implementation)

袁小林:沃尔沃专注于出行的安全感,并且把它做到极致

8月份加密市场的三个关键预期 价格虽向北移动?预计仍将处于动荡之中

基于DMS的数仓智能运维服务,知多少?
随机推荐
【码蹄集新手村600题】将一个函数定义宏
【Unity入门计划】制作RubyAdventure01-玩家的创建&移动
Optimal Power Flow (OPF) for High Voltage Direct Current (HVDC) (Matlab code implementation)
mysql delete 执行报错:You can‘t specify target table ‘doctor_info‘ for update in FROM clause
JD6606SP5_JD6606SSP_JD6606SASP_JD6621W7百盛新纪元授权代理商
用友YonSuite与旺店通数据集成对接-技术篇2
聊聊这个SaaS领域爆火的话题
NodeJs - cross domain
不可忽略!户外LED显示屏的特点及优势
不安装运行时运行.NET程序
语音识别新一轮竞争打响,自然对话会是下一个制高点吗?
Not to be ignored!Features and advantages of outdoor LED display
Introduction to the advantages of the new generation mesh network protocol T-Mesh wireless communication technology
Go Go 简单的很,标准库之 fmt 包的一键入门
ruoyi若依框架@DataScope注解使用以及碰到的一些问题
How to start an NFT collection
2021年数据泄露成本报告解读
window.open不显示favicon.icon
AWS中国区SDN Connector
扩展欧几里得求逆元实例