c++ - 在 Eclipse 中使用 Eigen3,无法编译

标签 c++ eclipse installation eigen

我下载了最新版本,并完全按照其自述文件中的描述执行方法 2:

Method 1. Installing without using CMake
****************************************

You can use right away the headers in the Eigen/ subdirectory. In order
to install, just copy this Eigen/ subdirectory to your favorite location.
If you also want the unsupported features, copy the unsupported/
subdirectory too.

Method 2. Installing using CMake
********************************

Let's call this directory 'source_dir' (where this INSTALL file is).
Before starting, create another directory which we will call 'build_dir'.

Do:

  cd build_dir
  cmake source_dir
  make install

终端显示它已正确安装,并且从 eclipse include 文件夹中我可以看到它安装在 usr/local/include 中, enter image description here

但是当我在 eclipse 中编译下面的测试程序时,我得到了这个:

#include <iostream>
#include <Eigen/Dense>
using Eigen::MatrixXd;
int main()
{
MatrixXd m(2,2);
m(0,0) = 3;
m(1,0) = 2.5;
m(0,1) = -1;
m(1,1) = m(1,0) + m(0,1);
std::cout << m << std::endl;
}

enter image description here

请帮帮我谢谢!

最佳答案

这说明了某些 Eigen 安装的问题: header 位于 include 文件夹中名为“eigen3”的子目录中,这意味着您的 include 语句必须是:

#include <eigen3/Eigen/Dense>

不推荐但会起作用。

相反,您应该 (1) 将 eigen3 文件夹添加到您的包含路径,然后在您的代码中,将包含语句保留为 #include <Eigen/Dense> .

或者,您可以 (2) 将 eigen3 中的 Eigen 文件夹向上移动一级,或者 (3) 将 Eigen 文件夹移动到其他位置并正确设置包含路径。在任何一种情况下,您的代码都会有 #include <Eigen/Dense> .

上面#1 是推荐的方法。

关于c++ - 在 Eclipse 中使用 Eigen3,无法编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16868216/

相关文章:

c++ - 使用 fork 执行多个命令

c++ - View Controller 中的 C 函数问题

java - 如何在eclipse中创建fcl项目

Eclipse 插件 - 使菜单项仅在选择特定元素时可见

以编程方式安装 Windows NDIS 中间 (IM) 驱动程序

c++ - 我们可以在 C++ 中使用 "wrap"模板类和非模板类吗?

java - 手动实例化 TestCase 并将其添加到 JUnit 不起作用

c# - 用户确认删除先前版本

python - 在 Mac 上安装 rpy 或 rpy2

c++ - 这段代码有什么问题?