Skip to main content

Installing Z3 C++ API

The Z3 C++ API provides a thin object-oriented layer on top of the Z3 C API. This page covers how to build Z3 from source and link it with your C++ projects.

Prerequisites

  • C++20 or later compiler
  • CMake 3.16 or later
  • Git (for cloning the repository)

Building Z3 from Source

Clone the Repository

Build with CMake

Install (Optional)

This will install:
  • Headers to /usr/local/include/ (including z3++.h)
  • Libraries to /usr/local/lib/
  • CMake config files for easy integration

Integrating Z3 into Your C++ Project

Create a CMakeLists.txt file for your project:
Build your project:

Manual Compilation

If you’re not using CMake, compile with:

Include the Header

In your C++ source files:

Verifying Installation

Create a simple test program:
test.cpp
Compile and run:
Expected output:

Build Options

Static vs Shared Library

By default, Z3 builds as a shared library. To build a static library:

Debug Build

For debugging with symbols:

Release Build with Optimizations

Troubleshooting

Library Not Found

If you get linker errors:
  1. Verify installation path:
  2. Add library path to LD_LIBRARY_PATH:

Header Not Found

If z3++.h is not found:

Windows-Specific

On Windows, copy the Z3 DLL to your executable directory:

Next Steps