当前位置:网站首页>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 文件的同级下
运行结果如下:
边栏推荐
- About DataFrame: Processing Time
- Black cat takes you to learn Makefile Part 11: When the header file a.h changes, how to recompile all the .c files that depend on the header file a.h
- xshell (sed command)
- Service - DNS forward and reverse domain name resolution service
- Live Classroom System 09--Tencent Cloud VOD Management Module (1)
- ENVI自动生成地面控制点实现栅格影像的自动地理配准
- Self-organization is a two-way journey between managers and members
- 微擎盲盒交友变现-vp_ph打开慢优化
- B. Codeforces Subsequences
- shell脚本循环语句for、while语句
猜你喜欢
APP UI自动化测试常见面试题,或许有用呢~
管理员必须知道的RADIUS认证服务器的部署成本
shell编程之免交互
翻译科技论文,俄译中怎样效果好
C. Even Picture
RADIUS Authentication Server Deployment Costs That Administrators Must Know
直播课堂系统08-腾讯云对象存储和课程分类管理
Thread State 详解
C # Hex file transfer skills necessary article 】 【 bin file code implementation
这些不可不知的JVM知识,我都用思维导图整理好了
随机推荐
ThreadLocal全面解析(一)
[Maui official version] Create a cross-platform Maui program, as well as the implementation and demonstration of dependency injection and MVVM two-way binding
Play RT-THREAD of doxygen
apr_thread使用内存之谜
Redis Command Manual
Labelme-5.0.1 version edit polygon crash
黑猫带你学Makefile第12篇:常见Makefile问题汇总
[SQL brush questions] Day3----Special exercises for common functions that SQL must know
labelme-屏蔽拖拽的事件
关于 DataFrame: 处理时间
管理员必须知道的RADIUS认证服务器的部署成本
阿里巴巴、蚂蚁集团推出分布式数据库 OceanBase 4.0,单机部署性能超 MySQL
Regular expression of shell programming and text processor
2022.8.9 Mock Competition
Thread State 详解
FPGA - 7系列 FPGA内部结构之Memory Resources -03- 内置纠错功能
【vulhub】MySql身份认证绕过漏洞复现(CVE-2012-2122)
这些不可不知的JVM知识,我都用思维导图整理好了
LeetCode-402-移掉K位数字
LeetCode-36-二叉搜索树与双向链表