How to Compile 7-Zip on Linux: Dependencies
Compiling 7-Zip from source on a Linux system requires a minimal set of build utilities, compilers, and optional assembly tools to optimize performance. This guide covers the essential dependencies needed for the compilation process, how to install them across popular Linux distributions, and the basic build steps required to produce a functional 7-Zip binary.
Core Dependencies
To compile the official 7-Zip source tree on Linux, you need:
- C/C++ Compilers (
gccandg++orclang): 7-Zip is written primarily in C and C++. A modern compiler supporting standard C++11 or newer is required. - GNU Make (
make): The build system uses standard makefiles located within the source tree to orchestrate compilation. - UASM or JWasm (Optional / Recommended for x86/x64):
7-Zip includes heavily optimized assembly routines for encryption (AES)
and compression algorithms (LZMA). Building with assembly support
requires an assembler compatible with MASM syntax, such as
uasm. If an assembler is not present, 7-Zip can still be built using pure C/C++ fallback routines by disabling ASM flags in the makefile.
Installing Dependencies by Distribution
Debian, Ubuntu, and Derivatives
Install the core development utilities using apt:
sudo apt update
sudo apt install build-essentialFor assembly optimizations, install uasm if available in
your repository, or download the binary release directly from the
official UASM project.
Fedora, RHEL, and CentOS
Install the base developer tools using dnf:
sudo dnf groupinstall "Development Tools"
sudo dnf install gcc gcc-c++ makeArch Linux
Install the base development meta-package:
sudo pacman -S base-develCompiling 7-Zip
Once the dependencies are installed:
Download and unpack the official 7-Zip source archive (e.g.,
7zXXXX-src.tar.xz).Navigate to the standalone console bundle directory:
cd CPP/7zip/Bundles/Alone2Run
makeusing the provided GCC makefile:make -f ../../cmpl_gcc.makNote: If building on an architecture without assembly tools or building without ASM support, use the non-ASM flag configuration specified inside
cmpl_gcc.makor compile fromCPP/7zip/Bundles/Alone.After the build completes, the compiled binary (
7zz) will be located in theb/gsubdirectory.