I am not getting the z3 ocaml binding working on windows 7. Here is the process I followed.
- Installed开发者_C百科 Objective Caml version 3.11.0 (Microsoft toolchain)
- Installed camlidl-1.05 (built it using Microsoft Visual Studio 2008 + cygwin)
- Installed z3-3.0
- Built z3 ocaml binding by running "build.cmd".The build was successful.
- Copied the files generated by "build.cmd" from z3/ocaml to ObjectiveCaml/lib
- Launched ocaml interactive and loaded "z3.cma" - # #load "z3.cma";; Characters -1--1: #load "z3.cma";; Error: The external function `get_theory_callbacks' is not available # Z3.mk_context;; Characters -1--1: Z3.mk_context;; Error: The external function `camlidl_z3_Z3_mk_context' is not available
Can someone please give me some hints?
EDIT 1: Building the example in "Z3-3.0\examples\ocaml":
Excerpt from build.cmd
set XCFLAGS=/nologo /MT /DWIN32
ocamlopt -ccopt "%XCFLAGS%" -o test_mlapi.exe -I ..\..\ocaml ole32.lib %OCAMLLIB%\libcamlidl.lib z3.cmxa test_mlapi.ml
I got the following error on executing build.cmd in the Visual Studio 2008 Command Prompt
** Fatal error: Cannot find file "/nologo"
File "caml_startup", line 1, characters 0-1:
Error: Error during linking
On removing the -ccopt "%XCFLAGS%", it works fine. The generated exe also executes as expected. ( Note that I have flexdll in PATH ). Any idea why this might be happening?
OCaml version 3.11 and later call the linker through flexdll, which does not need or know about the "/nologo /MT /DWIN32" flags. The ocaml\build.cmd script tests the ocaml version and sets XCFLAGS appropriately. I guess that examples\ocaml\build.cmd should be changed to do the same.
Using Z3 from the toplevel works for me if I create a custom toplevel by executing 'ocamlmktop -o ocamlz3 z3.cma' from Z3 ocaml bindings directory.
Here is what worked for me (Windows 7):
- Download and install Ocaml 3.08+ 
- Download and install Visual Studio C++ 
- Download and extract CamlIDL 
- Download and install cygwin, while installing choose the make package as well as your favorite linux editor package in a "Select package" window. 
- Open cygwin 
- In cygwin go to CamlIDL root directory 
- Rename config/Makefile.win32toconfig/Makefile
- Open config/Makefilewith an editor 
- Edit BINLIBandOCAMLLIBvariables 
- Save and exit the Makefile
- Setup c compiler for cygwin: Invoking cl.exe (MSVC compiler) in Cygwin shell 
- Run make allfrom CamlIDL root directory 
- Run make install
- Exit cygwin 
- Download and install Z3 
- Download and install FlexDLL: http://alain.frisch.fr/flexdll.html 
- Click Start, point to My Computer, right click, point to Properties, point to System Protection, choose Advanced Tab, point to Environment values... 
- Add C:\Program Files\flexdll\andC:\Program Files\Microsoft Research\Z3-<version-number>\bin\to the Path variable 
- Click Start, point to All Programs, point to Microsoft Visual Studio, point to Visual Studio Tools, and then click Visual Studio Command Prompt. 
- In Visual Studio Command Prompt go to C:\Program Files\Microsoft Research\Z3-<version-number>\ocaml
- Open build.cmdwith an editor 
- Remove %CD%variable from the last two commands 
- Save and close build.cmd
- Run build.cmd
- Copy z3* and libz3.lib files generated by build.cmd from z3/ocamlto%OCAMLLIB%
- Run ocamlmktop -o ocamlz3 z3.cma %OCAMLLIB%\libcamlidl.lib ole32.lib
- Run ocamlz3.exe
- Type #use "../examples/ocaml/test_mlapi.ml";;
- Try - simple_example();;
- The last step should produce a valid output from Z3. 
For Debian/Ubuntu:
- Install Ocaml 3.09+
 1. sudo apt-get install camlidl
- git clone git://github.com/polazarus/z3-installer.git(from Mickaël Delahaye)
- cd z3-installer
- make# download Z3 AND build the Ocaml library (native and byte)
- sudo make install# install Z3 binary, DLL and the Ocaml library
- sudo cp z3/lib/libz3.so /usr/lib/
- cd z3/ocaml
- ocamlmktop -o ocamlz3 z3.cma
- ./ocamlz3
- Try the following snippet:
let simple_example() =
begin
Printf.printf "\nsimple_example\n";
let ctx = Z3.mk_context_x (Array.append [|("MODEL", "true")|] [||]) in
Printf.printf "CONTEXT:\n%sEND OF CONTEXT\n" (Z3.context_to_string ctx);Z3.del_context ctx;
end;;
simple_example();;
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论