【问题标题】:Using Eigen3 in eclipse, cannot got it compiled在 Eclipse 中使用 Eigen3,无法编译
【发布时间】:2013-06-01 01:35:32
【问题描述】:

我下载了最新版本,并完全按照其自述文件中的描述执行方法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 包含文件夹中我可以看到它已安装在 usr/local/include 中,

但是当我在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;
}

请帮帮我,谢谢!

【问题讨论】:

  • 从屏幕截图来看,您已将标题放在eigen3 目录而不是Eigen 目录中。
  • 我应该放在哪里?谢谢。
  • 查找包含Dense 的名为Eigen 的文件夹,并确保它在您的目录结构中位于/usr/local/include 的正下方。 (我只是在这里猜测......首先尝试让它在命令行上工作以减少可变因素的数量)

标签: c++ eclipse installation eigen


【解决方案1】:

这说明了某些 Eigen 安装的问题:标头放置在包含文件夹中名为“eigen3”的子目录中,这意味着您的包含语句必须是:

#include <eigen3/Eigen/Dense>

不推荐,但可以。

您应该改为 (1) 将 eigen3 文件夹添加到您的包含路径中,然后在您的代码中将包含语句保留为 #include &lt;Eigen/Dense&gt;

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

上面的#1是推荐的方法。

【讨论】:

  • 不推荐使用此解决方案。替代方案 (1) 是正确的方法。
  • @ggael:谢谢。这就是我的暗示,但没有说清楚。编辑以反映 (1) 是正确的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-20
  • 1970-01-01
  • 1970-01-01
  • 2017-07-29
  • 1970-01-01
  • 2011-04-18
相关资源
最近更新 更多