Requirements
Compiler
- GCC
- Clang
GCC 4.8 or later (GCC 9+ recommended)Install on Debian/Ubuntu:
Build Tools
Assembler (Optional, for Performance)
For x86/x64 optimizations, install one of:- Asmc (Recommended)
- UASM
Asmc Macro Assembler - Recommended for full optimization
Quick Start
Navigate to a bundle directory and build:Build Configurations
7-Zip provides specialized makefiles for optimized builds:Basic Builds (No Assembler)
Optimized Builds (With Assembler)
Makefile Variables
You can customize builds using variables withmakefile.gcc:
Platform Control
Build for x86-64 architecture
Enable assembler optimizations
Specify assembler program
RAR Support Control
Remove all RAR-related code
Remove RAR decompression codecs (keeps archive listing support)
Assembler Selection
Use JWasm instead of Asmc (not recommended)
Build Examples
Standard x64 Build Without Assembler
b/g/7zz
Optimized x64 Build With Assembler
b/g_x64/7zz
Build Without RAR Support
Build With Custom UASM Assembler
Build Targets
Different bundle directories produce different binaries:| Directory | Output | Description |
|---|---|---|
Bundles/Alone2 | 7zz | Standalone binary (all formats) |
Bundles/Alone | 7za | Standalone binary (limited formats) |
Bundles/Alone7z | 7zr | Standalone binary (7z only) |
Bundles/Format7zF | 7z.so | Shared library (all formats) |
UI/Console | 7z | Console binary (requires shared lib) |
Compiler Flags
The build system uses the following optimization flags (from7zip_gcc.mak):
-flto- Link-time optimization (enabled in some configs)-ffunction-sections- Separate functions for linker optimization
Output Directory Structure
Builds create output in subdirectories:b/g/- GCC builds (general)b/g_x64/- GCC x64 buildsb/g_arm64/- GCC ARM64 builds_o/- Default output directory formakefile.gcc
Troubleshooting
Error: assembler not found
Error: assembler not found
If building with
USE_ASM=1 but assembler is missing:Error: pthread library not found
Error: pthread library not found
Install pthread development libraries:
Slow build performance
Slow build performance
Use the
-j flag to enable parallel compilation:Performance Comparison
Builds with assembler optimizations provide significant performance improvements:With Assembler (
cmpl_gcc_x64.mak):- Optimized CRC32 calculation
- Hardware AES encryption (if CPU supports)
- Faster LZMA compression/decompression
- Optimized SHA-256 hashing
cmpl_gcc.mak):- Uses C implementations for all codecs
- Portable to any architecture
- Slower but still functional
Cross-Compilation
To cross-compile for a different architecture:var_gcc.mak file supports the CROSS_COMPILE variable for setting the compiler prefix.
Next Steps
- Test your build:
./b/g/7zz --help - Benchmark performance:
./b/g/7zz b - Review build options
See Also
- Building Overview - General build information
- Building on Windows - MSVC builds
- Building on macOS - macOS builds