Can not build due to missing libgmp on macOS Monterey 12.5.1
chiro-hiro opened this issue · 4 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.
seems we share the same interest 🤭
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
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?.
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.