Error in including eigen library in c++

Hello,
I am using a program given in documentation of library eigen. Here is code:

1
2
3
4
5
6
7
8
9
10
11
12
13
  #include <iostream>
    #include <Eigen/Dense>
    using namespace Eigen;
    using namespace std;
    int main()
    {
      MatrixXd m = MatrixXd::Random(3,3);
      m = (m + MatrixXd::Constant(3,3,1.2)) * 50;
      cout << "m =" << endl << m << endl;
      VectorXd v(3);
      v << 1, 2, 3;
      cout << "m * v =" << endl << m * v << endl;
    }


When I tried to compile, I get error:

fatal error: Eigen/Dense: No such file or directory.

I am using gcc compiler. I copied the source files of eigen to directory of gcc. But still error is there. Can anyone suggest something? I am using codeblocks IDE.
Last edited on
From the Eigen website: http://eigen.tuxfamily.org/dox/GettingStarted.html
With GCC you use the -I option to achieve this, so you can compile the program with a command like this:
g++ -I /path/to/eigen/ my_program.cpp -o my_program


In Code::Blocks under Projects->Build Options->Compiler Settings->Other options put -I/path/to/eigen3
Alternatively, if you use pkg-config put `pkg-config --cflags eigen3` (note the backticks)
Topic archived. No new replies allowed.