zig
Compile Zig code
TLDR
Compile the project in the current directory
Compile and run the project in the current directory
Initialize a zig build project with library and executable
Create and run a test build
Cross compile, build and run a project for x86_64 architecture and windows operating system
Reformat Zig source into canonical form
Translate a C file to zig
Use Zig as a drop-in C++ compiler
SYNOPSIS
zig subcommand [options]
PARAMETERS
build
Build the project defined by the `build.zig` file.
run
Build and run the project.
test
Run the tests defined in the project.
init-exe
Initialize a new executable project.
init-lib
Initialize a new library project.
fmt
Format Zig source code according to the official style.
translate-c
Translates C code to Zig code.
-h or --help
Show help message and exit.
-v or --version
Display the Zig version.
DESCRIPTION
The `zig` command is the primary interface to the Zig programming language toolchain. It's a versatile command that encompasses compilation, linking, running, testing, and package management for Zig projects. It differentiates itself by prioritizing simplicity, transparency, and control over dependencies and build processes.
A key feature is its ability to cross-compile without external dependencies. This makes it ideal for building software for embedded systems or various target platforms. It supports various subcommands such as `build`, `run`, `test`, `init-exe`, `init-lib`, `fmt`, and more. The `build` subcommand serves as a build system that automatically manages dependencies specified in a `build.zig` file. It leverages a declarative build language, making build definitions more readable and maintainable. It also includes an integrated package manager that can fetch and link against external dependencies. Zig strives to provide a streamlined experience for software development and deployment by offering a comprehensive suite of tools within a single command.
BUILD SYSTEM
Zig includes a declarative build system driven by the `build.zig` file. This file defines build targets, dependencies, and other build-related settings in Zig code. This allows for build configurations to be written using the same language as the project. The build system is designed to be simple and extensible, allowing developers to define custom build steps and integrate with external tools. The build system supports incremental builds, caching, and other features to optimize build times.
PACKAGE MANAGER
Zig has a built-in package manager. Dependency management is done directly within the `build.zig` file. Zig offers reproducible builds and reliable dependency resolution.