7z libraries for C/C++
For C and C++ there are 3 good choices:
- libarchive reads and writes 7z with the same streaming API it uses for TAR, ZIP, CPIO and ISO. It’s on every Linux distribution and in macOS and Windows (
tar.exe). It can’t decrypt or create encrypted 7z archives. - LZMA SDK is the public-domain code by the author of 7-Zip. Its C part has a small 7z decoder (
7zArcIn.c,7zDec.c) with no dependencies, good for embedded use and installers. It reads LZMA, LZMA2, PPMd and BCJ/BCJ2 archives but not encrypted ones, and it doesn’t write 7z. - bit7z is a C++ wrapper of the 7-Zip shared library (
7z.dll,7z.so). It supports everything 7-Zip does: encryption, header encryption, all compression methods, multi-volume archives. You ship the 7-Zip library with your program.
Pick libarchive when you handle several archive formats and don’t need encryption; the LZMA SDK for a small, dependency-free extractor; bit7z when you need full 7-Zip features on Windows, Linux or macOS.
The full 7-Zip source code (C++, LGPL with an unRAR restriction for the RAR decoder) is at github.com/ip7z/7zip if you want to build a 7z encoder into your program directly.
- bit7z bit7z is a C++ wrapper of the 7-Zip shared library for reading and writing 7z archives. How to install it, extract, list, create encrypted 7z archives.
- libarchive libarchive reads and writes 7z archives in C and C++. How to install it, list and extract a 7z file, create a 7z archive with LZMA2.
- LZMA SDK The LZMA SDK is the public-domain reference code from the author of 7-Zip. How to build its C 7z decoder, list a 7z archive and extract files to memory.