- 编辑库代码
创建lib项目
![](https://www.icode9.com/i/ll/?i=0b9f8562074543dea2ae5acbaa5c4053.png?,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAbW9ua2V5a2luZF8=,size_20,color_FFFFFF,t_70,g_se,x_16)
使用Q_DECL_EXPORT关键字导出类,导出函数方式相同,在函数前加上extern "C" Q_DECL_EXPORT;
![](https://www.icode9.com/i/ll/?i=fdd69b59863a4c0cb4832d9b9f64fa97.png?,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAbW9ua2V5a2luZF8=,size_20,color_FFFFFF,t_70,g_se,x_16)
- 复制文件到需要引用的项目目录
讲xxx.h、xxx.lib、xxx.dll复制到要引用的项目目录中;
![](https://www.icode9.com/i/ll/?i=fa4c89bb5eb7459fbed97f8d9086f3bf.png?,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAbW9ua2V5a2luZF8=,size_20,color_FFFFFF,t_70,g_se,x_16)
- 连接库
使用#pragma comment(lib,"TestLib.lib")命令连接库,后即可正常调用库中的函数。
![](https://www.icode9.com/i/ll/?i=acc7426e8a1c4078a683d0f69b82c862.png?,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAbW9ua2V5a2luZF8=,size_20,color_FFFFFF,t_70,g_se,x_16)
2. 函数调用
![](https://www.icode9.com/i/ll/?i=d4193a0ce74245059e647bf1fd0c7cb9.png?,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAbW9ua2V5a2luZF8=,size_13,color_FFFFFF,t_70,g_se,x_16)
标签:DECL,qt,lib,xxx,dll,vs,EXPORT,函数
来源: https://blog.csdn.net/weixin_41492038/article/details/123190470