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)
- Headers to
/usr/local/include/(includingz3++.h) - Libraries to
/usr/local/lib/ - CMake config files for easy integration
Integrating Z3 into Your C++ Project
Using CMake (Recommended)
Create aCMakeLists.txt file for 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
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:-
Verify installation path:
-
Add library path to
LD_LIBRARY_PATH:
Header Not Found
Ifz3++.h is not found:
Windows-Specific
On Windows, copy the Z3 DLL to your executable directory:Next Steps
- Getting Started Guide - Write your first Z3 program
- API Reference - Explore available classes and methods
