threshold-signatures icon indicating copy to clipboard operation
threshold-signatures copied to clipboard

Can not build due to missing libgmp on macOS Monterey 12.5.1

Open chiro-hiro opened this issue 2 years ago • 3 comments

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.

chiro-hiro avatar Sep 13 '22 04:09 chiro-hiro

seems we share the same interest 🤭

tuphan-dn avatar Sep 16 '22 12:09 tuphan-dn

I recall that when I had this problem on new Mac Apple Silicon , I installed the lib:

brew install gmp I have checked what had been installed: brew list gmp

/opt/homebrew/Cellar/gmp/6.2.1_1/include/ (2 files) /opt/homebrew/Cellar/gmp/6.2.1_1/lib/libgmp.10.dylib /opt/homebrew/Cellar/gmp/6.2.1_1/lib/libgmpxx.4.dylib /opt/homebrew/Cellar/gmp/6.2.1_1/lib/pkgconfig/ (2 files) /opt/homebrew/Cellar/gmp/6.2.1_1/lib/ (4 other files) /opt/homebrew/Cellar/gmp/6.2.1_1/share/info/ (3 files)

and then I found that required library files already have symlinks in /opt/homebrew/lib, so that adding

export LIBRARY_PATH=/opt/homebrew/lib

to .profile ( or .zprofile ) solved the issue

RustMania avatar Sep 16 '22 13:09 RustMania

I recall that when I had this problem on new Mac Apple Silicon , I installed the lib:

brew install gmp I have checked what had been installed: brew list gmp

/opt/homebrew/Cellar/gmp/6.2.1_1/include/ (2 files) /opt/homebrew/Cellar/gmp/6.2.1_1/lib/libgmp.10.dylib /opt/homebrew/Cellar/gmp/6.2.1_1/lib/libgmpxx.4.dylib /opt/homebrew/Cellar/gmp/6.2.1_1/lib/pkgconfig/ (2 files) /opt/homebrew/Cellar/gmp/6.2.1_1/lib/ (4 other files) /opt/homebrew/Cellar/gmp/6.2.1_1/share/info/ (3 files)

and then I found that required library files already have symlinks in /opt/homebrew/lib, so that adding

export LIBRARY_PATH=/opt/homebrew/lib

to .profile ( or .zprofile ) solved the issue

Adding a .cargo/config could solve this problem for everyone. We just needed to figure out what is the different between arch and OS version?.

chiro-hiro avatar Sep 28 '22 06:09 chiro-hiro

ING has no intention of resolving this, nor on maintaining this further, and hence, this repo will be archived. Its usage is no longer recommended, see the updated README.

igmar avatar Sep 01 '23 15:09 igmar