⚡ Zig Guide LiveUnofficial
✓ Zig 0.17.0-dev.1454+5faa79730On an older Zig?

Installation

This guide tracks Zig master, not a tagged release. Every snippet here is compiled and executed against a fresh master build nightly, which is what keeps it correct. It also means a stable release will not compile some of these examples.

Getting master

The simplest route is a prebuilt tarball from ziglang.org/download. Take the one under master, not the latest release.

If you switch versions often, a version manager is worth it:

# zvm
zvm install master && zvm use master

# asdf
asdf install zig master && asdf global zig master

Verify:

zig version
# 0.16.0-dev.xxxx+xxxxxxxxx

A version without -dev in it is a tagged release, and several chapters here will not build against it.

Which version is this site?

The exact compiler that built and verified every snippet on this site is shown in the footer. If your local zig version differs, expect small divergences: master moves daily.

An editor

ZLS is the language server, and it must match your compiler version reasonably closely. Build it from source against your Zig if you are on master; a ZLS built for an older release will report spurious errors on current syntax.

Nothing else required

Zig is a single binary. It ships its own C compiler, cross-compiles to every supported target out of the box, and needs no separate build tool (zig build is part of it). There is no toolchain to assemble.