Important: Please read the Qt Code of Conduct -

Qt5 cannot find header files - OpenSuse

  • This may be a regular question but so far I couldn't find an answer.

    The following error appears when trying to compile:

    g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I../qtbase/mkspecs/linux-g++-64 -I. -I. -I../qtbase/include -I../qtbase/include/QtGui -I../qtbase/include/QtCore -I. -o a.o a.cpp
    a.cpp:1:24: fatal error: QApplication: No such file or directory

    This happens when I run with qmake -project --> qmake --> make. As well as from c++ directly:

    fatal error: QApplication: No such file or directory

    It cannot find any header, although they are all there in ../qtbase/include/ . It seems something with the configure, i.e., before the compilation, which by the way ran without errors.

    The code I ran is the first in

    I appreciate any help.

  • Hi jrfaria,

    Ran into the same problem. I think I've figured this out now. This solution is based on this "post": .

    Apparently in Qt5 qtwidgets is a module which is apart from qtgui (in contrast to qt4). Therefore adding

    @QT += widgets@

    to your .pro file should do the job (it seems qmake is the culprit).

    So to compile you would do something like

    qmake -project -> (if needed, add "QT += widgets" to the .pro file) -> qmake -> make.

    I've tried this on a couple of the qt examples and it has worked.

    Hope it helps.

Log in to reply