Trouble with Z3 on OCaml 4.10 on Linux and OCaml 4.x on macOS

I have read and upvoted your answers before.

For this one, the direct solution works for me

ocamlfind ocamlmktop -thread -custom -linkpkg -package z3 -o z3top

However, I cannot make the dune version answer in the post. For dune 2.5.1, utop 2.5.0 and OCaml 4.10.0,

(executable
 (name z3utop)
 (link_flags -linkall -custom -cclib -lstdc++)
 (libraries utop z3))

Building with this dune file gets error message

File "dune", line 2, characters 7-13:
2 |  (name z3utop)
           ^^^^^^
Error: File unavailable:
/home/exx/.opam/4.10.0+flambda/lib/ocaml/compiler-libs/ocamltoplevel.cmxa
File "dune", line 2, characters 7-13:
2 |  (name z3utop)
           ^^^^^^
Error: File unavailable: /home/exx/.opam/4.10.0+flambda/lib/utop/uTop.a
File "dune", line 2, characters 7-13:
2 |  (name z3utop)
           ^^^^^^
Error: File unavailable: /home/exx/.opam/4.10.0+flambda/lib/utop/uTop.cmxa
File "_none_", line 1:
Warning 58: no cmx file was found in path for module UTop_main, and its interface was not compiled with -opaque

EDIT: this works. the error message won’t show so I delete it.
If I add a (modes byte) as dune doc suggests, it works.
I don’t figure it out for some time. Then I found this dune issue on GitHub and it works magically.

1 Like