0

I downloaded the latest version and did the method2 exactly as described in its readme file:

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

and the terminal shows it correctly installed and from the eclipse include folder I can see it is installed in usr/local/include, enter image description here

but when I compile the following test program in eclipse, I got this:

#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

Please help me out thanks!

4

1 回答 1

2

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

#include <eigen3/Eigen/Dense>

不建议这样做,但会起作用。

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

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

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

于 2013-06-01T03:37:03.160 回答