当前位置:网站首页>QT笔记——用VS + qt 生成dll 和 调用生成的dll
QT笔记——用VS + qt 生成dll 和 调用生成的dll
2022-08-10 21:25:00 【旧街凉风°】
用VS + qt 生成dll 和 调用生成的dll
环境: vs 2019 + qt 5.12
第一步: 创建一个qt 的 类库
第二步:创建类库的样子:
.h文件 需要包含 qt为我们生成的 导入 和 导出 宏
可以看一下这个宏
# define Q_DECL_EXPORT __declspec(dllexport)
# define Q_DECL_IMPORT __declspec(dllimport)
创建的时候 qt 已经为我们创建好了 预编译的 宏
第三步:我们需要确定创建的是动态库
我需要创建的是 x64位,release 的 dll,根据自己代码 是否需要添加qt 的模块
我的 是网络库 ,所以需要 我添加 network 模块
否则会出现如下情况:
当然我们也可以手动添加 QT的网络库,根据自己的喜爱把,上面的肯定方便一些
连接库:Qt5Network.lib
连接路径:$(QTDIR)\lib
包含头路径:$(QTDIR)\include\QtNetwork
第四步:生成我们的dll
我们可以选择我们生成的dll的 名字 和 路径,这里只是简单测试,就不改名字了
生成的如下:
第五步:调用我们生成的dll
我们随便建立一个QT程序
配置我们的程序,让我们的程序可以使用刚才创建的dll,包含库的目录include,和lib目录和加载的.lib
代码如下:
以为大功告成了?还差一步
我们需要将 dll 放到我们的.exe 文件的同级下
运行结果如下:
边栏推荐
猜你喜欢
阿里巴巴、蚂蚁集团推出分布式数据库 OceanBase 4.0,单机部署性能超 MySQL
Shell programming specification and variables
[SQL brush questions] Day3----Special exercises for common functions that SQL must know
【PCBA方案】电子握力测试仪方案she‘ji
An article to teach you a quick start and basic explanation of Pytest, be sure to read
HighTec shortcut keys (Keys) setting location
Uniapp编译后小程序的代码反编译一些思路
财务年报怎样翻译,为什么要选择专业翻译公司?
Kerberos认证
一篇文章教你Pytest快速入门和基础讲解,一定要看
随机推荐
Service - DNS forward and reverse domain name resolution service
DDL:CREATE 创建数据库——《mysql 从入门到内卷再到入土》
[Maui official version] Create a cross-platform Maui program, as well as the implementation and demonstration of dependency injection and MVVM two-way binding
Bedtime story | made a Bitmap and AST length system configuration
Live Classroom System 08 Supplement - Tencent Cloud Object Storage and Course Classification Management
TCL:事务的特点,语法,测试例——《mysql 从入门到内卷再到入土》
LeetCode-36-二叉搜索树与双向链表
LeetCode-402 - Remove K digits
基于Pix4Dmapper的运动结构恢复法无人机影像三维模型重建
DDL:视图——《mysql 从入门到内卷再到入土》
ACM模板笔记:最长不下降/上升子序列
【PCBA方案】电子握力测试仪方案she‘ji
为什么一般公司面试结束后会说「回去等消息」,而不是直接告诉面试者结果?
智能方案设计——智能跳绳方案
In 2021 China industrial Internet security competition (competition) in fujian province and the first industry of fujian province Internet innovation competition
shell(文本打印工具awk)
Live Classroom System 09--Tencent Cloud VOD Management Module (1)
Application of Spatial 3D Model Reconstruction Based on Pix4Dmapper - Spatial Analysis and Site Selection
shell编程之免交互
Likou 221 questions, the largest square