If you replace
#include <Eigen/Dense>
by
#include <eigen3/Eigen/Dense>
your code will compile. In other words, the problem is that you are including <Eigen/Dense>
which is in the directory /usr/include/eigen3
, but the compiler only searches in /usr/include
by default.
I would recommend using include flags, instead of including <eigen3/Eigen/Dense>
, because this is more portable across distributions, operating systems, etc. and generally, it is easier to configure compilation for other environments. Eigen3 comes with pkg-config files, which are very easy to use and portable. Compiling with
g++ $(pkg-config --cflags eigen3) test1.cpp
will work on all platforms, where pkg-config is available and it is a great alternative for you, if you want to avoid the hard-coded include paths.