Solved Qt cannot find the header files
-
Hi All,
I'm running a simple code using libigl (a simple geometry library) and Eigen libraries. So, I added their paths in the .pro file by
INCLUDEPATH += "[mypath]/C_libraries/libigl/include" INCLUDEPATH += "[mypath]/C_libraries/eigen/Eigen"
The above paths are the libraries' directories. All the header files are available in the mentioned paths. But when I trying following code, Qt cannot find header files:
#include <igl/cotmatrix.h> #include <Eigen/Dense> #include <Eigen/Sparse> #include <iostream> int main() { Eigen::MatrixXd V(4,2); V<<0,0, 1,0, 1,1, 0,1; Eigen::MatrixXi F(2,3); F<<0,1,2, 0,2,3; Eigen::SparseMatrix<double> L; igl::cotmatrix(V,F,L); std::cout<<"Hello, mesh: "<<std::endl<<L*V<<std::endl; return 0; }
Qt can find first header (cotmatrix.h from igl), but for next one I got following error:
error: Eigen/Dense: No such file or directory
12 | #include <Eigen/Dense>
| ^~~~~~~~~~~~~could you please let me know why does it happen? How can I resolve it?
I'm using Ubuntu 20.4 on iMac machine. -
Do you have "[mypath]/C_libraries/eigen/Eigen/Eigen/Dense" file? (That's three eigen OMG...)
I think your include path might should be "[mypath]/C_libraries/eigen" -
@Bonnie Hi, that's not three eigen. It's "[mypath]/C_libraries/eigen/Eigen/Dense". Yes, its available in the mentioned directory. I tried "[mypath]/C_libraries/eigen", but it cannot find the header files.
-
@Hassan-math You should try with "[mypath]/C_libraries" as it is trying to include "#include <Eigen/Dense>"...
-
@jsulm I tried, but it doesn't work. Same error...
-
@Hassan-math said in Qt cannot find the header files:
It's "[mypath]/C_libraries/eigen/Eigen/Dense".
Then it should be "[mypath]/C_libraries/eigen".
Rerun qmake after you modify the .pro file, better also clean and rebuild.Tip:
If you use "[mypath]/C_libraries/eigen/Eigen" as include path, then you should only#include <Dense> #include <Sparse>
But this will have problems if the header files includes <Eigen/xx> in themselves.
-
@Hassan-math You should do a complete clean rebuild after changing pro file: delete build folder, run qmake and build.
-