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:

  1. C/C++ Compilers (gcc and g++ or clang): 7-Zip is written primarily in C and C++. A modern compiler supporting standard C++11 or newer is required.
  2. GNU Make (make): The build system uses standard makefiles located within the source tree to orchestrate compilation.
  3. 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-essential

For 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++ make

Arch Linux

Install the base development meta-package:

sudo pacman -S base-devel

Compiling 7-Zip

Once the dependencies are installed:

  1. Download and unpack the official 7-Zip source archive (e.g., 7zXXXX-src.tar.xz).

  2. Navigate to the standalone console bundle directory:

    cd CPP/7zip/Bundles/Alone2
  3. Run make using the provided GCC makefile:

    make -f ../../cmpl_gcc.mak

    Note: If building on an architecture without assembly tools or building without ASM support, use the non-ASM flag configuration specified inside cmpl_gcc.mak or compile from CPP/7zip/Bundles/Alone.

  4. After the build completes, the compiled binary (7zz) will be located in the b/g subdirectory.