zkcrypto / bellman

zk-SNARK library.
Other
988 stars 534 forks source link

Can not build due to missing libgmp on macOS Monterey 12.5.1 #92

Closed chiro-hiro closed 2 years ago

chiro-hiro commented 2 years ago

Build error

error: linking with `cc` failed: exit status: 1
[....]
  = note: ld: library not found for -lgmp
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: could not compile `ecdsa-mpc` due to previous error

How to fix?

Install GMP with homebrew:

brew install gmp

Make sure gmp linked:

brew link --force gmp

Create file .cargo/config in source code folder:

[target.x86_64-apple-darwin]
rustflags = [
  "-L", "/opt/homebrew/lib",
  "-L", "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib",
  "-C", "link-arg=-undefined",
  "-C", "link-arg=dynamic_lookup",
]

[target.aarch64-apple-darwin]
rustflags = [
  "-L", "/opt/homebrew/lib",
  "-L", "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib",
  "-C", "link-arg=-undefined",
  "-C", "link-arg=dynamic_lookup",
]

These flags was used to guide rustc to look up libraries from homebrew. I'm prefer an official patch.