Skip to main content
Z3 can be built on Windows using Visual Studio’s command-line tools (nmake) or the Visual Studio IDE with CMake integration.

Prerequisites

  • Visual Studio 2019 or later (recommended for C++20 support)
  • Python (for build configuration with mk_make.py)
  • CMake 3.16+ (for CMake-based builds)
Z3 uses C++20, so Visual Studio 2019 or later is recommended for full language support.

Quick Start with Command Line

1

Open Developer Command Prompt

Launch the “Developer Command Prompt for Visual Studio” or “x64 Native Tools Command Prompt” from the Start menu.
2

Configure the build

For a 32-bit build:
For a 64-bit build:
3

Build with nmake

Using Visual Studio IDE with CMake

Visual Studio 2019+

Visual Studio 2019 and later have integrated CMake support:
1

Open the Z3 folder

In Visual Studio, select File → Open → Folder and navigate to the Z3 repository root directory.
2

Configure CMake

Visual Studio will automatically detect CMakeLists.txt and begin configuration. You can customize CMake options in CMakeSettings.json.
3

Select build configuration

Choose your build configuration (Debug, Release, etc.) from the dropdown in the toolbar.
4

Build the project

Select Build → Build All or press Ctrl+Shift+B.

Legacy Visual Studio Versions

For older Visual Studio versions, use CMake GUI:
1

Create build directory

Create an empty directory for build outputs.
2

Launch CMake GUI

Start the cmake-gui application.
3

Configure paths

  • Set “Where is the source code” to the Z3 repository root
  • Set “Where to build the binaries” to your empty build directory
4

Configure the project

  1. Click Configure
  2. Select your Visual Studio version as the generator
  3. Choose platform (Win32 for 32-bit, x64 for 64-bit)
  4. Click Finish
5

Adjust options

Modify any CMake options as needed. Click Configure again after changes.
6

Generate solution

Click Generate to create the Visual Studio solution file.
7

Build in Visual Studio

  1. Open the generated Z3.sln file in the build directory
  2. Select your build type (Debug/Release) in Visual Studio
  3. Build the solution with Build → Build Solution

Security Features (MSVC)

When building with MSVC, Z3 enables several security features by default to protect against exploitation:

Control Flow Guard (CFG)

Enabled by default - Control Flow Guard protects against control flow hijacking attacks:
  • Compiler flag: /guard:cf
  • Linker flag: /GUARD:CF
  • Purpose: Validates indirect call targets at runtime to prevent attackers from redirecting control flow

With Python Build System

Disable if needed:

With CMake

Disable if needed:
Control Flow Guard is enabled by default on MSVC builds and provides important security hardening.

Address Space Layout Randomization (ASLR)

Automatically enabled with Control Flow Guard:
  • Linker flag: /DYNAMICBASE
  • Purpose: Randomizes memory addresses to make exploitation more difficult
  • Note: Required for Control Flow Guard to function

Incompatibilities

Control Flow Guard is incompatible with:
  • /ZI - Edit and Continue debug information format
  • /clr - Common Language Runtime compilation
When these options are detected, CFG is automatically disabled with a warning.
Control Flow Guard is incompatible with Edit and Continue (/ZI). Use /Zi for debug builds instead.

Build Configurations

With Python Script (nmake)

With CMake and NMake

Ninja is recommended over NMake for significantly faster builds.

With CMake and Ninja

Ninja is much faster than NMake:

Language Bindings

.NET Bindings

Build with .NET support:
Z3 also provides a NuGet package at nuget.org/packages/Microsoft.Z3.

Python Bindings

Build inside the Visual C++ native command prompt:
The build/python/z3 directory must be accessible from where Python runs, and libz3.dll must be in the PATH.

Java Bindings

For IDE setup and troubleshooting, see the Java IDE Setup Guide.

Static vs Shared Library

Static Library (default)

Shared Library (DLL)

Visual Studio Generator Selection

When using CMake GUI, select the appropriate generator:
Generators with “Win64” in the name indicate 64-bit builds. Without it, they’re 32-bit builds.

CMake Configuration Options

Common options for Visual Studio builds:
See the CMake build guide for a complete list of options.

Multi-Configuration Builds

Visual Studio is a multi-configuration generator - you don’t set the build type when running CMake:
With command-line tools:

Installation

Install to a specific location:

Troubleshooting

C++20 Errors

Ensure you’re using Visual Studio 2019 or later:

Python Not Found

Add Python to your PATH or specify the full path:

Missing DLL at Runtime

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

Control Flow Guard Warnings

If you see CFG incompatibility warnings, either:
  1. Disable Edit and Continue (use /Zi instead of /ZI)
  2. Disable Control Flow Guard: -DZ3_ENABLE_CFG=OFF

CMake Can’t Find Visual Studio

Run CMake from the Developer Command Prompt, or specify the generator explicitly:

Build Performance

Parallel Builds

With nmake (single-threaded), consider using Ninja instead:
With MSBuild (Visual Studio):

Incremental Builds

Ninja provides much faster incremental builds than NMake:

Next Steps