示例:使用homebrew安装eigen

brew install eigen

安装完成后,路径应该是

/opt/homebrew/Cellar/eigen/3.4.0/include/eigen3/

如果不确定或者找不到可以使用以下指令直接打印出来路径

brew list eigen

结果应该是:

(base) xxx@xxx~ % brew list eigen
/opt/homebrew/Cellar/eigen/3.4.0/include/eigen3/ (532 files)
/opt/homebrew/Cellar/eigen/3.4.0/share/cmake/Modules/FindEigen3.cmake
/opt/homebrew/Cellar/eigen/3.4.0/share/eigen3/ (4 files)
/opt/homebrew/Cellar/eigen/3.4.0/share/pkgconfig/eigen3.pc

将安装路径或者打印出的第一个路径写在CLion下的CMakeList.txt中

include_directories("/opt/homebrew/Cellar/eigen/3.4.0/include/eigen3/")

即可实现对eigen的调用,可以测试下写eigen的调用

#include <Eigen/Core>
#include <Eigen/Dense>

查看是否报错,若无报错则配置完成。

配置GMP大数运算库

参考博客:https://www.freesion.com/article/1695995357/

方法二:直接用Homebrew安装GMP

brew install gmp

查看安装路径,

$ brew list gmp
/opt/homebrew/Cellar/gmp/6.3.0/include/ (2 files)
/opt/homebrew/Cellar/gmp/6.3.0/lib/libgmp.10.dylib
/opt/homebrew/Cellar/gmp/6.3.0/lib/libgmpxx.4.dylib
/opt/homebrew/Cellar/gmp/6.3.0/lib/pkgconfig/ (2 files)
/opt/homebrew/Cellar/gmp/6.3.0/lib/ (4 other files)
/opt/homebrew/Cellar/gmp/6.3.0/sbom.spdx.json
/opt/homebrew/Cellar/gmp/6.3.0/share/info/ (3 files)

将安装路径或者打印出的第一个路径写在CLion下的CMakeList.txt中

include_directories("/opt/homebrew/Cellar/gmp/6.3.0/include/")

即可实现对eigen的调用,可以测试下写eigen的调用

#include <gmp.h>
#include <gmpxx.h>

查看是否报错,若无报错则配置完成。