问题
I want to use Z3 with C++, and I followed the installation guide - Building Z3 on Windows using Visual Studio Command Prompt.
I built it successfully, then I also added the build path to the system path. However, I still got an error when I was trying to run the example.cpp file. The error says [Error] z3++.h: No such file or directory
. Can anyone tell me is there any other configuration I need to do after building Z3 using Visual Studio Command Prompt successfully in order to run Z3 with c++?
回答1:
Did you add the z3\src\api\c++
and z3\src\api
path to your include directories when compiling?
If you're working with a Visual Studio project, you need to add it in the project properties under "C++" -> "Additional Include Directories".
When compiling manually using cl
, you can use the /I[path]
command line parameter (https://msdn.microsoft.com/en-us/library/73f9s62w.aspx).
You will also have to add the z3.lib
to your compilation once you actually start using the z3
API in your code, lest you receive undefined reference
errors. In Visual Studio, that's "Linker" -> "Additional Dependencies" and optionally "Additional Library Directories" if you're using a relative path to the library.
In my environment, the following command line gets your example program compiled: cl example.cpp /I C:\tools\z3\z3-master\src\api\c++ /I C:\tools\z3\z3-master\src\api C:\tools\z3\z3-master\build\libz3.lib
来源:https://stackoverflow.com/questions/51993350/how-to-use-z3-with-c