IagoAbal / haskell-z3

Haskell bindings to Microsoft's Z3 API (unofficial).
Other
57 stars 45 forks source link

Unable to install on M1/M2 Mac #89

Open niconaus opened 1 year ago

niconaus commented 1 year ago

I'm running into issues installing Haskell z3 on my m2 MacBook. I've ran the following commands:

brew install z3
cabal install z3 --lib

This results in the following error message:

Resolving dependencies...
Build profile: -w ghc-9.2.8 -O1
In order, the following will be built (use -v for more details):
 - z3-408.2 (lib) (requires build)
Starting     z3-408.2 (lib)

Failed to build z3-408.2. The failure occurred during the configure step.
Build log ( /Users/nna/.cabal/logs/ghc-9.2.8/z3-408.2-14ff341a.log ):
Configuring library for z3-408.2..
cabal-3.6.2.0: Missing dependency on a foreign library:
* Missing (or bad) header file: z3.h
* Missing (or bad) C library: z3
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.If the
library file does exist, it may contain errors that are caught by the C
compiler at the preprocessing stage. In this case you can re-run configure
with the verbosity flag -v3 to see the error messages.
If the header file does exist, it may contain errors that are caught by the C
compiler at the preprocessing stage. In this case you can re-run configure
with the verbosity flag -v3 to see the error messages.

cabal: Failed to build z3-408.2. See the build log above for details.

Since I'm on M2 Mac, it seems like homebrew will install z3 in a different location:

% brew info z3          
==> z3: stable 4.12.2 (bottled), HEAD
High-performance theorem prover
https://github.com/Z3Prover/z3
/opt/homebrew/Cellar/z3/4.12.2 (118 files, 30.6MB) *
  Poured from bottle using the formulae.brew.sh API on 2023-09-05 at 12:33:32
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/z/z3.rb
License: MIT
==> Dependencies
Build: cmake ✘, python@3.11 ✘
==> Options
--HEAD
    Install HEAD version
==> Analytics
install: 16,081 (30 days), 42,436 (90 days), 92,273 (365 days)
install-on-request: 343 (30 days), 1,161 (90 days), 3,556 (365 days)
build-error: 403 (30 days)

From the error message from Haskell z3, I would suspect that then the following should work, but it does not:

cabal install z3 --lib --extra-lib-dirs=/opt/homebrew/Cellar/z3/4.12.2/lib --extra-include-dirs=/opt/homebrew/Cellar/z3/4.12.2/include

Any help would be greatly appreciated!

tmoux commented 1 year ago

I haven't tested this myself, but it looks like this question has the same problem and a solution: https://stackoverflow.com/questions/77253044/installing-z3-binding-with-haskell-on-mac. The problem it identifies is that your homebrew installed version 4.12.2, which isn't compatible with Haskell z3-408.3.