Documentation Index
Fetch the complete documentation index at: https://mintlify.com/facebook/zstd/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Zstandard is designed to be highly portable and supports major operating systems including Linux, macOS, Windows, and various Unix-like systems.Linux
Standard Build
On most Linux distributions with standardmake or gmake:
Installation Paths
Default installation follows GNU standards:- Binaries:
/usr/local/bin/ - Libraries:
/usr/local/lib/ - Headers:
/usr/local/include/ - Man pages:
/usr/local/share/man/
Multiarch Support
For multiarch systems (Debian/Ubuntu), libraries should be installed to architecture-specific directories:- x86_64
- ARM64
pkg-config files.
Multithreading on POSIX
Multithreading on Linux requires:- Build macro:
-DZSTD_MULTITHREAD - Link with pthread:
-pthread
pkg-config Integration
After installation, usepkg-config:
MT=1 when installing:
macOS
Build from Source
Homebrew
Install via Homebrew:Dynamic Library Differences
macOS uses different shared library conventions:- Extension:
.dylibinstead of.so - Versioning:
libzstd.1.dylib(major version) - Install name: Uses
-install_nameinstead of-soname
Universal Binaries (Apple Silicon + Intel)
Build fat binaries supporting both architectures using CMake:- Apple Silicon (M1/M2/M3)
- Intel Macs (x86_64)
CMake versions 3.14+ are recommended for iOS-derived platforms.
iOS Framework
Build iOS framework:Windows
MinGW + MSYS
Build with MinGW:dll\libzstd.dll- Dynamic librarydll\libzstd.lib- Import library (for Visual C++)
Compiling Applications
With MinGW/gcc:dll\libzstd.dll at runtime.
Visual Studio
Multiple options available in thebuild/ directory:
- CMake (Recommended)
- VS2010 Project
- Automated Scripts
vcpkg Integration
- Multi-architecture builds
- Debug/Release configurations
- Integration with Visual Studio
AIX
On AIX systems, the Makefile automatically adjusts:Cross-Platform Considerations
Target System Detection
The build system detects the target platform:Cross-Compilation
When cross-compiling from Linux to Windows:CC- Cross compilerTARGET_SYSTEM- Target OSUNAME_TARGET_SYSTEM- Target uname output
Endianness
Zstandard automatically handles endianness. All magic numbers are read/written using little-endian convention, with automatic conversion on big-endian systems.Compiler-Specific Features
BMI2 Instructions (x86_64)
- Static BMI2
- Dynamic BMI2
Intrinsics
Disable explicit intrinsics:Assembly Optimizations
On x86_64 Linux, assembly optimizations are automatically enabled. To disable:Memory Usage
Decoder Buffer Size
Control internal decompression buffer size:Testing
Quick Smoke Tests
Comprehensive Tests
Without Make
Ifmake is unavailable:
Troubleshooting
pthread linking errors on Linux
pthread linking errors on Linux
Ensure you’re linking with For static multithreaded library:
-pthread:Missing DLL on Windows
Missing DLL on Windows
Ensure
libzstd.dll is:- In the same directory as your executable
- In a directory listed in
PATH - Or statically link instead
Multiarch installation conflicts
Multiarch installation conflicts
Use architecture-specific library directories:
BMI2 performance issues
BMI2 performance issues
Some CPUs don’t benefit from BMI2. Disable if needed:
Next Steps
Build Systems
Integrate with Make, CMake, Meson, Bazel, or Buck
C/C++ Integration
Learn the C/C++ API