美文网首页
error: 'Eigen/Core' file not fou

error: 'Eigen/Core' file not fou

作者: Hamiltonian | 来源:发表于2024-07-11 11:55 被阅读0次

首先你要先使用brew安装过Eigen3 。 然后你在使用这个库的时候,你会天真的以为在CMakeLists中这样写:

find_package(Eigen3 REQUIRED)

include_directories(${Eigen3_INCLUDE_DIRS})

然后你在你的CPP文件中也能#include <eigen3/Eigen/Eigen> ,宽且也能提示到。但是编译就报错了

fatal error: 'eigen3/Eigen/Core' file not found

此时,你会看看你的 /usr/local/include/eigen3目录,一切都正常呀?其实这个是因为在Mac上 /usr 目录下面没有include 目录,include目录放在了local目录下面了。可能是cmake找不到吧,我猜的。

因此你的CMakeLists就不能那么写了,因该把上面的常规写法注释掉,或者删除掉,改用下面的写法

include_directories("/usr/local/include/eigen3/")

直接这样写,简单粗暴。然后在你的C++文件中直接这样引用

#include <Eigen/Core>

#include <unsupported/Eigen/FFT>

然后你就可以愉快的使用Eigen了。

相关文章

网友评论

      本文标题:error: 'Eigen/Core' file not fou

      本文链接:https://www.haomeiwen.com/subject/mxhxhjtx.html