This document explains how to build ZEVM on different platforms (macOS, Linux, Windows).
ZEVM is designed to work on:
- macOS (tested on macOS 14+)
- Linux (tested on Ubuntu/Debian-based systems)
- Windows (Windows 10/11, requires MSVC or MinGW toolchain)
The build system (build.zig) automatically detects the target platform and adjusts:
- Default include paths for required libraries
- Library linking (e.g., math library
libmis Unix-only) - Platform-specific library names
blst and mcl) are required by default. If you see "library not found" errors, you need to install these libraries before building. See the "Required Libraries" section below for installation instructions.
Easiest way to build:
make # Auto-detects OS, installs deps, and builds
make install-deps # Install dependencies only
make build # Build only (assumes deps are installed)
make test # Run testsThe Makefile automatically:
- Detects your operating system
- Installs required dependencies
- Builds the project with correct options
See the Makefile for more options and customization.
# Auto-detect OS and build
make
# Install dependencies only
make install-deps
# Build without blst or mcl
make BLST_ENABLED=false MCL_ENABLED=false
# Custom include paths
make BLST_INCLUDE=/path/to/blst/bindings MCL_INCLUDE=/path/to/mcl/include# Standard build (blst is required by default)
zig build
# Build with custom include path (if blst built from source)
zig build -Dblst-include=/path/to/blst/bindings
# Disable blst if needed (not recommended)
zig build -Dblst=falseInstalling dependencies:
brew install libsecp256k1 openssl
# Build blst from source (required, not available via Homebrew)
# See "Required Libraries" section below for installation instructions# Standard build (blst is required by default)
zig build
# Build with custom include path (if blst installed in non-standard location)
zig build -Dblst-include=/usr/include
# Disable blst if needed (not recommended)
zig build -Dblst=falseInstalling dependencies (Ubuntu/Debian):
sudo apt-get update
sudo apt-get install -y libsecp256k1-dev libssl-dev
# Build blst from source (required)
# See "Required Libraries" section below for installation instructionsInstalling dependencies (Fedora/RHEL):
sudo dnf install libsecp256k1-devel openssl-devel# Standard build (blst is required by default)
zig build
# Build with custom include path (if blst installed in non-standard location)
zig build -Dblst-include="C:/vcpkg/installed/x64-windows/include"
# Disable blst if needed (not recommended)
zig build -Dblst=falseInstalling dependencies on Windows:
-
Using vcpkg (recommended):
vcpkg install secp256k1 openssl # Optional: vcpkg install blst -
Using pre-built binaries:
- Download OpenSSL from: https://slproweb.com/products/Win32OpenSSL.html
- Download secp256k1 or build from source
- Set include paths using
-Dblst-include=...and-Dmcl-include=...
The build system uses platform-specific defaults:
- macOS/Linux:
/usr/local/include(standard Unix location) - Windows:
C:/Program Files(users should override with-Dblst-include=...)
You can always override defaults:
zig build -Dblst-include=/custom/path/to/blst/include
zig build -Dmcl-include=/custom/path/to/mcl/includeThe build system automatically handles:
- Math library (
libm): Only linked on Unix systems (not needed on Windows) - OpenSSL: Uses standard names (
ssl,crypto) on all platforms - secp256k1: Uses standard name on all platforms
Zig supports cross-compilation out of the box:
# Build for Linux from macOS
zig build -Dtarget=x86_64-linux-gnu
# Build for Windows from macOS/Linux
zig build -Dtarget=x86_64-windows
# Build for macOS from Linux
zig build -Dtarget=x86_64-macosWhen cross-compiling, you may need to:
- Install target-specific libraries
- Specify custom include paths for the target platform
- Use
zig ccto compile C dependencies for the target
All precompile dependencies are required by default. You can disable them individually with -Dblst=false or -Dmcl=false if needed, but this will disable the corresponding precompiles.
Status: Required by default, enables BLS12-381 precompiles and KZG point evaluation
Note: You can disable blst with -Dblst=false, but this will disable BLS12-381 and KZG precompiles.
Installation:
macOS (build from source):
# Clone the repository
git clone https://github.com/supranational/blst.git
cd blst
# Build the library
./build.sh
# Install (optional, or use custom include path)
# The library will be in ./libblst.a
# Headers will be in ./bindings/
# You can then use: zig build -Dblst=true -Dblst-include=/path/to/blst/bindingsLinux (build from source):
# Clone the repository
git clone https://github.com/supranational/blst.git
cd blst
# Build the library
./build.sh
# Install system-wide (optional)
sudo make install
# Or use custom include path: zig build -Dblst=true -Dblst-include=/path/to/blst/bindingsWindows (build from source or vcpkg):
# Option 1: Build from source (requires Visual Studio or MinGW)
git clone https://github.com/supranational/blst.git
cd blst
# Follow Windows build instructions in the repository
# Option 2: Use vcpkg (if available)
vcpkg install blstUsage:
# If installed system-wide
zig build -Dblst=true
# If using custom path
zig build -Dblst=true -Dblst-include=/path/to/blst/bindingsNote: The blst library is not available via Homebrew on macOS, so you must build it from source. See the official repository for detailed build instructions.
Status: Required by default, enables BN254 precompiles
Note: You can disable mcl with -Dmcl=false, but this will disable BN254 precompiles.
Installation:
macOS (build from source):
# Clone the repository
git clone https://github.com/herumi/mcl.git
cd mcl
# Build the library
# Follow the build instructions in the repository
# Note: mcl is primarily C++, so C bindings may need to be createdLinux (build from source):
# Clone the repository
git clone https://github.com/herumi/mcl.git
cd mcl
# Build the library
# Follow the build instructions in the repositoryWindows (build from source or vcpkg):
# Option 1: Build from source (requires Visual Studio or MinGW)
git clone https://github.com/herumi/mcl.git
cd mcl
# Follow Windows build instructions in the repository
# Option 2: Use vcpkg (if available)
vcpkg install mclUsage:
# Standard build (mcl enabled by default)
zig build
# If using custom include path
zig build -Dmcl-include=/path/to/mcl/include
# Disable mcl (not recommended, disables BN254 precompiles)
zig build -Dmcl=falseNote: The mcl library is primarily C++, so C bindings may need to be created or you may need to use mcl's C API if available. See the official repository for detailed build instructions.
If you see errors like:
error: unable to find dynamic system library 'blst' using strategy 'paths_first'
error: unable to find dynamic system library 'mcl' using strategy 'paths_first'
This means the required libraries are not installed. Here's how to fix it:
Quick Fix:
- Install blst: See the "Required Libraries" section above for installation instructions
- Install mcl: See the "Required Libraries" section above for installation instructions
- Rebuild: Run
zig buildagain
If you can't install the libraries right now:
- You can temporarily disable them:
zig build -Dblst=false -Dmcl=false - Note: This will disable BLS12-381, KZG, and BN254 precompiles
Other common issues:
- Libraries installed but not found:
- Check library installation: Verify libraries are installed and accessible
- Specify include paths: Use
-Dblst-include=...or-Dmcl-include=... - Check library paths: Ensure libraries are in system library paths or use
-Lflags - On macOS with Homebrew: Libraries are typically in
/opt/homebrew/libor/usr/local/lib - On Linux: Libraries are typically in
/usr/libor/usr/local/lib
- MSVC vs MinGW: Zig uses its own toolchain, but you may need MSVC runtime on Windows
- Path separators: Use forward slashes (
/) or escaped backslashes (\\) in paths - Library names: Some libraries may have different names (e.g.,
libssl.avsssl.lib)
- Package managers: Different distributions use different package managers
- Library versions: Ensure compatible versions of OpenSSL and secp256k1
- Development headers: Install
-devor-develpackages, not just runtime libraries
The project includes GitHub Actions workflows that test on:
- Ubuntu Latest (Linux)
- macOS Latest
Windows support can be added by adding a Windows runner to the CI matrix.
To test cross-platform compatibility:
# Test Linux build from macOS
zig build -Dtarget=x86_64-linux-gnu
# Test Windows build from macOS/Linux
zig build -Dtarget=x86_64-windows
# Run tests for specific target
zig test src/precompile/tests.zig -I src -target x86_64-linux-gnuThe build system is designed to work cross-platform with minimal configuration:
- ✅ Automatic platform detection
- ✅ Platform-specific defaults
- ✅ Override options for custom installations
- ✅ Cross-compilation support
- ✅ All precompile dependencies are required by default
blst(BLS12-381 and KZG) - can be disabled with-Dblst=falsemcl(BN254) - can be disabled with-Dmcl=false
- ✅ Other required libraries:
secp256k1,openssl(ssl/crypto),libm(Unix)
Important: All precompile dependencies (blst and mcl) are now required by default. You must install them before building. See the "Required Libraries" section above for installation instructions.
For most users, after installing the required libraries, zig build should work out of the box.