I am dealing with a fatal error: QApplication: No such file or directory
, similar to this and this post. I have attempted the proposed solutions with no avail. I am running the code using wsl
on Windows 10, which is to say that to run the code I
Navigate to the project's folder.
Open the command prompt.
Run
> wsl
Run
$ code .
After VSCode opens, I open a new terminal and run
$ qmake -project $ qmake $ make
The output of which is
g++ -c -pipe -O2 -Wall -Wextra -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_GUI_LIB -
DQT_CORE_LIB -I. -I. -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o Main.o Main.cpp
Main.cpp:1:10: fatal error: QApplication: No such file or directory
1 | #include <QApplication>
| ^~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:1275: Main.o] Error 1
A few things I have tried or verified:
The newest versions of
qmake
andQt
are installed:$ qmake -v QMake version 3.1 Using Qt version 5.15.13 in /usr/lib/x86_64-linux-gnu
My
.pro
file contains all necessary lines, the first couple being:QT += core gui QT += widgets
Checking the location of
Qt
:$ qmake -query QT_INSTALL_HEADERS /usr/include/x86_64-linux-gnu/qt5
and manually forcing the .pro
file to include Qt
by adding the following lines to the .pro
:
INCLUDEPATH += /usr/include/x86_64-linux-gnu/qt5
INCLUDEPATH += /usr/include/x86_64-linux-gnu/qt5/QtWidgets
INCLUDEPATH += /usr/include/x86_64-linux-gnu/qt5/QtCore
Using
pkg-config
, by adding the linesCONFIG += link_pkgconfig PKGCONFIG += Qt5Widgets Qt5Gui Qt5Core QMAKE_CXXFLAGS += -fPIC
to the .pro
and running
$ qmake
$ make clean
$ make
I am dealing with a fatal error: QApplication: No such file or directory
, similar to this and this post. I have attempted the proposed solutions with no avail. I am running the code using wsl
on Windows 10, which is to say that to run the code I
Navigate to the project's folder.
Open the command prompt.
Run
> wsl
Run
$ code .
After VSCode opens, I open a new terminal and run
$ qmake -project $ qmake $ make
The output of which is
g++ -c -pipe -O2 -Wall -Wextra -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_GUI_LIB -
DQT_CORE_LIB -I. -I. -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o Main.o Main.cpp
Main.cpp:1:10: fatal error: QApplication: No such file or directory
1 | #include <QApplication>
| ^~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:1275: Main.o] Error 1
A few things I have tried or verified:
The newest versions of
qmake
andQt
are installed:$ qmake -v QMake version 3.1 Using Qt version 5.15.13 in /usr/lib/x86_64-linux-gnu
My
.pro
file contains all necessary lines, the first couple being:QT += core gui QT += widgets
Checking the location of
Qt
:$ qmake -query QT_INSTALL_HEADERS /usr/include/x86_64-linux-gnu/qt5
and manually forcing the .pro
file to include Qt
by adding the following lines to the .pro
:
INCLUDEPATH += /usr/include/x86_64-linux-gnu/qt5
INCLUDEPATH += /usr/include/x86_64-linux-gnu/qt5/QtWidgets
INCLUDEPATH += /usr/include/x86_64-linux-gnu/qt5/QtCore
Using
pkg-config
, by adding the linesCONFIG += link_pkgconfig PKGCONFIG += Qt5Widgets Qt5Gui Qt5Core QMAKE_CXXFLAGS += -fPIC
to the .pro
and running
$ qmake
$ make clean
$ make
Share
Improve this question
edited Mar 4 at 12:01
Sam
asked Mar 4 at 2:02
SamSam
4761 gold badge5 silver badges19 bronze badges
7
|
Show 2 more comments
1 Answer
Reset to default 0With Qt 5 and 6 I have had to also add QtWidgets/ to the #include <> to access QApplication.
#include <QtWidgets/QApplication>
Also mentioned here.
QApplication
file should be in the/usr/include/x86_64-linux-gnu/qt5/QtWidgets
folder I believe (or at least its in a similar location on my Gentoo server). I typedfind /usr/include/qt5 -name 'QApplication'
becauseqmake -query QT_INSTALL_HEADERS
returned/usr/include/qt5
– drescherjm Commented Mar 4 at 3:23find /usr/include/x86_64-linux-gnu/qt5 -name QApplication
gives/usr/include/x86_64-linux-gnu/qt5/QtWidgets/QApplication
. As shown in the post, the/usr/include/x86_64-linux-gnu/qt5
directory is included in the.pro
, so it should be able to findQApplication
, right? – Sam Commented Mar 4 at 11:23