I read the documentation of Eigen installation. As per the documentation, only header files need to be referred in your project. As shown in the screenshot below, I included the path of the Eigen in my include directories, but the program does not recognize Eigen.
Sample Code:
#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;
}
How do I correctly include the Eigen into my C++ project?
>Solution :
You added path/to/eigen-3.4.0/Eigen
to your include path, but then you include the header Eigen/Dense
, so this looks for path/to/eigen-3.4.0/Eigen/Eigen/Dense
. That’s one Eigen
too many.
Set the include path to path/to/eigen-3.4.0
instead.
(Don’t be tempted to modify the include to #include <Dense>
instead. It might cause Eigen to be unable to find its own headers, and can also easily lead to naming conflicts.)