3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-09-05 20:24:24 +00:00
z3/examples/c++
Alex Reinking 69a4be91b2
[CMake] Use z3::libz3 as the preferred way to consume Z3 (#10733)
In #10717 we enhanced the CMake package to support multiple build
configurations, so that Z3 could be installed and consumed as either a
static or shared package, or both side by side. This PR dog-foods that
work: the Python bindings and the example projects now consume Z3
through the same installed CMake package that external users rely on,
rather than through separate in-tree plumbing.

To make that possible, we introduce a `z3::libz3` ALIAS that mirrors the
installed target in-tree. In-tree consumers (like the examples and the
Python bindings) and out-of-tree consumers of the installed package now
refer to Z3 the same way, so now there's one blessed interface. The
examples and package-consumer test were updated accordingly, both to
exercise this path and to serve as a model for how downstream projects
should consume Z3 going forward.

Finally, we add test coverage for the reworked Python build, including a
CI job that installs a shared build of libz3 and then builds the Python
bindings against that installed package, confirming the Python-only
build path works end to end.
2026-09-04 13:33:23 -07:00
..
CMakeLists.txt [CMake] Use z3::libz3 as the preferred way to consume Z3 (#10733) 2026-09-04 13:33:23 -07:00
example.cpp fix C++ example and add polymorphic interface for C++ 2025-10-29 03:08:49 -07:00
README Refer to macOS rather than Mac OS / OSX. 2018-10-02 17:38:09 +07:00

Small example using the c++ bindings.
To build the example execute
   make examples
in the build directory.

This command will create the executable cpp_example.
On Windows, you can just execute it.
On macOS and Linux, you must install z3 first using
   sudo make install
OR update LD_LIBRARY_PATH (Linux) or DYLD_LIBRARY_PATH (macOS) with the build directory. You need that to be able to find the Z3 shared library.