Skip to main content
The Make-based build system uses a Python script (mk_make.py) to generate Makefiles, which are then used to compile Z3. This approach is simple and works well for Unix-like systems.
For building OCaml bindings, the Make-based system is required. For other use cases, CMake is recommended.

Prerequisites

  • Python (for running mk_make.py)
  • GCC or Clang compiler
  • Make
  • Git (optional)

Basic Build

1

Generate Makefiles

Run the Python configuration script:
2

Build Z3

Navigate to the build directory and compile:
3

Install (optional)

Install Z3 system-wide:

Compiler Selection

By default, g++ is used if available. To use Clang:
Clang versions older than 3.7 do not support OpenMP and may have limited parallel processing capabilities.

Cross-Platform Builds

Windows with Cygwin and MinGW

You can build Z3 for Windows using Cygwin and the MinGW-w64 cross-compiler:
Make sure to use Cygwin’s own Python, not a Windows installation of Python.

Installation Prefix

The default installation prefix varies by platform:
  • Linux: /usr
  • FreeBSD/macOS: /usr/local
To change the installation prefix:
Z3 will be installed to:
  • Binaries: PREFIX/bin
  • Libraries: PREFIX/lib
  • Headers: PREFIX/include

Build Configuration Options

Language Bindings

Enable specific language bindings:

Python Package Directory

For non-standard installation prefixes, specify the Python package directory:
A better approach for non-standard prefixes is to use a Python virtual environment.

Using Virtual Environments

Install Z3 in a Python virtual environment:

Architecture-Specific Builds

32-bit vs 64-bit

The build system automatically detects your system architecture. For Windows builds using the Visual Studio Command Prompt, you can explicitly specify: 32-bit build:
64-bit build:
See the Visual Studio build guide for Windows-specific instructions.

Managing Builds

Cleaning

To clean the build, delete the build directory and regenerate:

Uninstalling

Dependencies

Z3 has minimal dependencies:
  • C++ runtime libraries - including pthreads for multi-threading
  • Python - required for build configuration
  • GMP (optional) - for multi-precision integers (Z3 has built-in alternative)

Using GMP

To use the GNU Multiple Precision library instead of Z3’s built-in implementation:
Note: When using CMake, this option is: -DZ3_USE_LIB_GMP=ON

Platform-Specific Notes

Linux

Standard build works out of the box:

macOS

Installs to /usr/local by default:

FreeBSD

Similar to macOS, installs to /usr/local:

Cygwin

For 64-bit builds from Cygwin64:

Building Specific Components

OCaml Bindings

The Make build system is required for OCaml bindings:
OCaml bindings cannot be built with the CMake build system. Use the Make-based build.

Go Bindings

Go bindings use CGO and require Go 1.20 or later:
The Go bindings require the Z3 C API and will work with both the Make and CMake build systems.

Common Use Cases

Development Build

Quick build for development:

Production Build with Python

Optimized build with Python bindings:

All Bindings

Build with all available bindings:

Compiler Flags

The mk_make.py script handles most compiler flag configuration automatically. For custom flags, you can set environment variables:

Comparison with CMake

Troubleshooting

Python Not Found

Ensure Python is in your PATH:

Compiler Not Found

Verify your compiler is installed and accessible:

Permission Denied During Install

Use sudo for system-wide installation:
Or install to a user directory:

Build Failures

Clean and rebuild:

Next Steps