2

I have just started using QtCreator (and C++ after 15 years away from it). I want to do some linear algebra stuff so I have included the library Eigen in my project file as follows (I have placed the Eigen library directly in my project for the moment):

INCLUDEPATH = "/home/Software/QtProjects/MyProject/eigen/"

My source file is:

#include <QCoreApplication>
#include <iostream>
#include <Eigen/Dense> % 'Eigen/Dense' file not found

using Eigen::MatrixXd; % use of undeclared identifier 'Eigen'

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    MatrixXd m(2,2); % unknown type name 'MatrixXd'

    m(0,0) = 3;
    m(1,0) = 2.5;
    m(0,1) = 8;
    m(1,1) = m(1,0) + m(0,1);
    std::cout << m << std::endl;

    return a.exec();
}

This code works and outputs the values of the matrix m in the console. However, in the QtCreator IDE, I have several error messages which I have included above as comments on the lines at which they appear.

So is there some way to fix this and make QtCreator stop showing these lines as errors when the code is actually working fine?

sonicboom
  • 4,928
  • 10
  • 42
  • 60

2 Answers2

0
houssam
  • 1,823
  • 15
  • 27
0

On Linux, run

sudo apt-get install libeigen3-dev

Then add this to your .pro file

INCLUDEPATH += /usr/include/eigen3

And then run qmake

Colin McGovern
  • 105
  • 1
  • 6