Installing Zig
This guide will help you install Zig on your system. There are multiple ways to get Zig depending on your platform and needs.Download Pre-built Binaries
The easiest way to get started with Zig is to download pre-built binaries from the official website.Visit the Zig downloads page
Navigate to ziglang.org/download to find the latest release for your platform.
Choose your platform
Zig provides pre-built binaries for:
- Linux (x86_64, aarch64, riscv64, loongarch64, s390x)
- macOS (x86_64, aarch64)
- Windows (x86_64, aarch64)
- FreeBSD (x86_64)
Building from Source
You can build Zig from source for maximum control and to contribute to development.Prerequisites
Building Zig from source requires:- CMake 3.15 or later
- C and C++ compiler (GCC, Clang, or MSVC)
- Ninja build system (recommended)
- LLVM, Clang, and LLD libraries (optional, for LLVM backend)
Build with CMake
Configure with CMake
The CMakeLists.txt:1-38 defines the build configuration:
The default install prefix is
stage3 in the build directory. Override with -DCMAKE_INSTALL_PREFIX.Build with Zig (Bootstrap)
If you already have Zig installed, you can use it to build the latest version:Common Build Options
From build.zig and CMakeLists.txt:-Doptimize=ReleaseFast- Optimize for speed-Doptimize=ReleaseSmall- Optimize for binary size-Doptimize=Debug- Debug build with safety checks-Dtarget=<triple>- Cross-compile for specific target-Dno-lib- Skip copying lib/ files (for development)-Denable-llvm- Enable LLVM backend-DZIG_STATIC=ON- Build static binary (CMake)
Package Managers
- Homebrew (macOS)
- apt (Debian/Ubuntu)
- pacman (Arch Linux)
- Chocolatey (Windows)
- Scoop (Windows)
Verify Installation
After installation, verify that Zig is properly installed:Next Steps
Now that you have Zig installed, you’re ready to write your first program!Quick Start Guide
Learn how to create and build your first Zig program