c++qtvisual-studio-2017visual-studio-community

Error Cannot open include file: 'GLES2/gl2.h': No such file or directory suddenly appears


I've compiled my project many times over, both in release and debug configuration. Suddenly, an error appears:

Cannot open include file: 'GLES2/gl2.h': No such file or directory

This is a Qt project in Visual Studio 2017 Community with the Qt add-in, using Qt 5.6.1-64.

I tried to search on google but there seems to be no advice that applies to this issue.


Solution

  • I will document my steps for fixing this, it may help even if you have a different issue.

    1. I watched which cpp file triggers the error
    2. I commented it out completely, then re-added lines until error appeared
    3. It was triggered by an #include statement
    4. I enabled the Include tree output from the compiler
    5. I found that the include comes from QtXlsx library which includes <QtGui/QtGui> through C:\Qt\5.6.1-64\include\QtXlsx\QtXlsxDepends. Note that we use GUI in this project, so there must be additional issue that causes this.

    I commented out #include <QtGui/QtGui> from the QtXlsxDepends file. I noted this to myself to find the real cause of the error.

    However everything compiles and works after this change. I will improve this answer after further investigation.