YouTip LogoYouTip

Zig Setup

# Zig Environment Setup When configuring the development environment for the Zig programming language, you need to install the Zig compiler and set up related development tools. The following are the steps to configure Zig on different operating systems: ## Install Using Package Manager ### Windows Zig is available on Chocolatey: choco install zig Windows (winget) winget install zig.zig Windows (scoop): scoop install zig ### MacOS Homebrew installation: brew install zig ### Linux Ubuntu (snap) Stable version installation: snap install zig --classic --beta Fedora: dnf install zig FreeBSD: pkg install lang/zig After configuration, you can start developing with the Zig programming language. ## Source Code Installation We can also download the source code to compile and install. Zig source package download address: [https://ziglang.org/zh/download/](https://ziglang.org/zh/download/). !(#) After downloading, use the tar command to extract: tar -xvf zig-macos-aarch64-0.13.0.tar.xz Then enter the source package for subsequent compilation and installation: cd zig-macos-aarch64-0.13.0 You can also clone the source code from Zig's GitHub repository: git clone https://github.com/ziglang/zig.git ### Dependencies * cmake >= 3.5 * gcc >= 7.0.0 or clang >= 6.0.0 * LLVM, Clang, LLD development libraries == 18.x, compiled with the same version of gcc or clang * Can be installed using system package manager, or built from source. ### Instructions 1. In the Zig source directory, create a build directory: mkdir build cd build 2. Run cmake: cmake .. 3. Build and install Zig: make install Please note the convenient cmake variable `CMAKE_PREFIX_PATH`. CMake will prioritize searching for LLVM and other dependencies in this location. These steps will generate `stage3/bin/zig`, which is the Zig compiler built by Zig itself. ### macOS + Homebrew For macOS using Homebrew: 1. In the Zig source directory, create a build directory: mkdir build cd build 2. Run cmake with static LLVM enabled: cmake .. -DZIG_STATIC_LLVM=ON -DCMAKE_PREFIX_PATH="$(brew --prefix llvm@18);$(brew --prefix zstd)" 3. Build and install Zig: make install ### FreeBSD For FreeBSD: 1. Install necessary dependencies using pkg: sudo pkg install -qyr FreeBSD devel/llvm18 devel/cmake archivers/zstd textproc/libxml2 archivers/lzma 2. In the Zig source directory, create a build directory: mkdir build cd build 3. Run cmake with static LLVM enabled: cmake .. -DZIG_STATIC_LLVM=ON -DCMAKE_PREFIX_PATH="/usr/local/llvm18;/usr/local" 4. Build and install Zig: make install These steps will install the Zig compiler on your system.
← Zig CommentsDocker Volume Command β†’