Skip to main content
The Z3 C API is the core interface to Z3 and is automatically included with all Z3 distributions. All other language bindings are built on top of the C API.

Prerequisites

  • C compiler (GCC, Clang, MSVC, or compatible)
  • CMake (optional, for building from source)
  • Python 3.x (for building from source)

Installation Options

Download the latest Z3 release for your platform from the GitHub Releases page.
The pre-built binaries include:
  • include/z3.h - Main C API header
  • include/z3_*.h - Additional API headers
  • bin/libz3.so (Linux) / bin/libz3.dylib (macOS) / bin/libz3.dll (Windows) - Shared library

Option 2: Build from Source

Building from source gives you the latest features and allows customization.

Option 3: Package Managers

Verify Installation

Create a test file test_z3.c:
test_z3.c
Compile and run:
Expected output:

Linking with Z3

GCC/Clang

If Z3 is installed in a non-standard location:

CMake

Add to your CMakeLists.txt:

Visual Studio

  1. Add include directory: Project Properties → C/C++ → General → Additional Include Directories: C:\z3\include
  2. Add library directory: Project Properties → Linker → General → Additional Library Directories: C:\z3\bin
  3. Add library: Project Properties → Linker → Input → Additional Dependencies: libz3.lib

Runtime Configuration

Linux/macOS

If Z3 is not installed in a standard location, set LD_LIBRARY_PATH (Linux) or DYLD_LIBRARY_PATH (macOS):

Windows

Ensure libz3.dll is in your PATH or in the same directory as your executable.

Troubleshooting

Header Not Found

Solution: Add the Z3 include directory to your compiler’s include path using -I.

Library Not Found

Solution: Add the Z3 library directory using -L or install Z3 to a standard location.

Runtime Library Error

Solution: Set LD_LIBRARY_PATH or run sudo ldconfig after installation.

Next Steps

Getting Started

Learn the basics of the Z3 C API

API Reference

Explore the complete C API documentation