TAR libraries for C/C++
- libarchive is the standard choice. It reads and writes ustar, pax, GNU and v7 archives, handles gzip, bzip2, xz, zstd and lz4 compression itself, detects the format automatically, and extracts to disk with safety checks. It’s the library behind
bsdtar, thetarcommand of macOS, FreeBSD and Windows. BSD license. - microtar is 2 small C files under the MIT license. It reads and writes basic tar headers (100-byte names, files under 4 GB) with no compression and no dependencies. Use it for embedded systems or to pack a few files into a resource bundle; it hasn’t been updated since 2017.
Pick libarchive for anything that reads archives made by other programs. Pick microtar only when you control both the writer and the reader and want zero dependencies.
- libarchive libarchive reads and writes TAR (ustar, pax, GNU) and .tar.gz, .tar.xz, .tar.zst in C. How to list, extract safely and create tar archives, with code examples.
- microtar microtar is a tiny MIT-licensed C library that reads and writes basic TAR archives with no dependencies. How to list, read and write tar files, and its limits.