本文使用bit7z
bit7z is a C++ static library which allows to compress and extract many file archive formats, all through a clean, simple and entirely object-oriented interface to the dynamic libraries from the 7-zip project (https://www.7-zip.org/).
It supports compression and extraction to and from the filesystem or the memory, reading of archives metadata, updating existing archives, creation of multi-volume archives, operation progress callbacks and many other functionalities.
开发环境
- VS2019
- windows10
需要的文件
下载文件
- 进入7-Zip下载Extra文件
- 进入Bit7z v3.1.2下载bit7z-v3.1.2-msvc2019_x64.7z文件
创建项目
- 在vs2019中创建空项目
配置dll与lib
- 打开项目目录,将文件7z1900-extra.7z解压并将x64下的7zxa.dll与7za.dll与文件bit7z-v3.1.2-msvc2019_x64.7z中的lib与include文件夹解压到项目根目录。
将以上选择的文件复制到项目根目录,此时项目目录如下
- 配置vs2019,将解决方案平台设置为x64,将头文件、lib导入vs2019
将lib加入附加库目录
在输入中附加依赖项键入bit7z64.lib与bit7z64_d.lib
最后再添加到命令行
此添加lib方式参考
https://www.jianshu.com/p/43f889a2b91e
测试运行
- 在项目中创建main.cpp
键入以下代码:
#include "include/bitexception.hpp"
#include "include/bitarchiveinfo.hpp"
#include <iostream>
using namespace std;
using namespace bit7z;
int main() {