最近有qt项目需要压缩文件,在网上搜寻了一圈,找到Quazip开源库,截止到2022.1.16,最新版可在github下载到(适用于qt6)。但GitHub上该项目由cmake生成,不知道怎么导入qt项目。经过两天的不断试错和借鉴网上资料,找到了将其引入项目的方法,现记录于此。 关于cmake与qmake是什么,详见:https://www.zhihu.com/question/27455963 注:本项目为QT6.1.3,mingw编译器
1.在GitHub上下载Quazip并解压
 解压后如上图
2.打开qtcreator,打开文件或项目,选择上图中的CMakeLists.txt打开,选择mingw编译器,点右下角锤子构建一下,生成Debug文件
   这一步就是用qtcreator构建cmake项目,生成对应的dll与a(lib)文件
3.在自己的项目中,.pro的同级目录下新建一个include文件夹和一个lib文件夹,将Quazip开源库中所有的.h文件拷贝到include文件夹中
 
4.进入构建QuaZip生成的debug文件,找到生成的.dll文件和.a(.lib)文件,将其中.a(.lib)文件拷贝到自己项目的lib文件夹下,将.dll文件拷贝到自己项目生成的debug/release版本中.exe同级目录下
   
5.在自己项目中添加依赖库
右键项目->添加库,选择外部库  库文件选择自己项目中lib下拷贝过去的.a(.lib)文件,包含路径选择自己创建的include文件夹  
到此就可以在自己项目中引用quazip开源库了! 
同理,其他cmake项目导入qt项目中都是通过.dll,.a(.lib)以及所有的.h文件联系起来的
参考文章: https://www.cnblogs.com/qiyawei/p/10695192.html https://www.zhihu.com/question/27455963
|