首页 > 解决方案 > 无法链接 gmp:找不到 -lgmp 的库

问题描述

我正在尝试fastecdsa通过运行安装在 macOS BigSur(M1 芯片)上

(venv) $ pip3 install fastecdsa

即使我以前安装过gmp

$ brew install gmp

无论我做什么,它都找不到库

    src/curve.h:4:10: fatal error: 'gmp.h' file not found
    #include "gmp.h"

虽然在我创建符号链接时错误发生了变化

ln -s /opt/homebrew/include/gmp.h /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include

现在我得到:

    ld: library not found for -lgmp
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    error: command '/usr/bin/gcc' failed with exit code 1

我也试过:

LDFLAGS=-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib pip3 install fastecdsa
CFLAGS=-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include pip3 install fastecdsa

我不能把我的手指放在它上面:(

标签: gccclangmacos-big-surgmpapple-m1

解决方案


你现在可能已经解决了这个问题,但只是说我遇到了类似的事情,我的解决方案是告诉我ld查看自制库路径。运行此/将其添加到~/.profile

export LIBRARY_PATH=$LIBRARY_PATH:/opt/homebrew/lib
export INCLUDE_PATH=$INCLUDE_PATH:/opt/homebrew/include

(在我的情况下,我不需要 INCLUDE_PATH,但看起来你可能需要!)

在那之后,也许您的 python 命令将开始工作!


推荐阅读