我用了brew install gcc,brew install gmp。但是,clang 可以使用选项"-lgmpxx"编译器并在 g++ 失败时成功我使用了这个命令:
g++ bn_p.cpp -o bn_p.out -lgmpxx -lgmp -Xpreprocessor -fopenmp
它说:
fatal error: gmpxx.h: No such file or directory
4 | #include <gmpxx.h>
使用自制软件安装似乎不是正确的方法,我建议遵循另一个答案的说明,该答案似乎遵循某种最佳实践
如果您仍然更喜欢使用 brew 进行安装,我通过运行解决了我的问题
brew info gmp
返回安装路径,例如我的是:
/opt/homebrew/Cellar/gmp/6.2.1_1
然后,您只需要在编译命令中包含包含文件夹作为库搜索路径,例如:
g++ main.cpp -o app -I /opt/homebrew/Cellar/gmp/6.2.1_1/include