Qt6 QMake
-
Hi,
I've just installed Qt6 on Ubuntu using the command
sudo apt install qt6-base-dev
and when I create a Makefile with QMake6 for a simple C++ project that opens a QWidget, the compilation fails because it can't find QApplication header.
The command executed by the makefile is
g++ -c -pipe -O2 -Wall -Wextra -fPIC -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I. -I. -I/usr/include/x86_64-linux-gnu/qt6 -I/usr/include/x86_64-linux-gnu/qt6/QtGui -I/usr/include/x86_64-linux-gnu/qt6/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt6/mkspecs/linux-g++ -o main.o main.cpp
How to solve this ?
Thank you
-
When you want to use widgets, you should specify it in your pro file.
See e.g. https://doc.qt.io/qt-6/qlabel.html -
When you want to use widgets, you should specify it in your pro file.
See e.g. https://doc.qt.io/qt-6/qlabel.html@Christian-Ehrlicher Thank you for your reply.
I think I did specify it in my .pro file but the compiler still can't find it.My project file is this one :
TEMPLATE = app TARGET = main QT += core gui widgets CONFIG += c++11 SOURCES += main.cpp
-
Your compiler output does not match the pro file. Rerun qmake on a clean build dir
-
Your compiler output does not match the pro file. Rerun qmake on a clean build dir
@Christian-Ehrlicher It worked.
Thank you.
This time QMake generated a different project file :###################################################################### # Automatically generated by qmake (3.1) Sun Dec 8 19:29:47 2024 ###################################################################### TEMPLATE = app TARGET = Qt_First_Project INCLUDEPATH += . # You can make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # Please consult the documentation of the deprecated API in order to know # how to port your code away from it. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 # Input SOURCES += main.cpp
I added QT += gui core widgets and the compilation was successful.