Coding Global Background
Coding Global

Cmake cannot find QT6 and I don't know why

Archived a month ago
18 messages
3 members
Created 2 months ago
Updated a month ago
Open in Discord
N
DokkitheAstronaut
Script Kiddie!
Hello so I keep getting this error:

g++.exe C:\Users\Vince\Desktop\AppointmentSchedulingSoftware-main\AppointmentSchedulingSoftware-main\main.cpp -o main
C:\Users\Vince\Desktop\AppointmentSchedulingSoftware-main\AppointmentSchedulingSoftware-main\main.cpp:2:10: fatal error: QApplication: No such file or directory
2 | #include <QApplication>
| ^~
compilation terminated.

And I have no idea why it keeps saying no such file or directory when I have it clearly listed in the CMakeLists.txt file here:

cmake_minimum_required(VERSION 3.31)
project(AppointmentSchedulingSoftware)



set(CMAKE_CXX_STANDARD 17)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOMOC ON)

if(UNIX)
set(CMAKE_PREFIX_PATH "/usr/lib/x86_64-linux-gnu/cmake")
elseif(WIN32)
set(CMAKE_PREFIX_PATH "C:/Users/Vince/Documents/QT/6.10.1/mingw_64")
endif()

find_package(Qt6 REQUIRED COMPONENTS Widgets Sql)

add_executable(AppointmentSchedulingSoftware
main.cpp
MainAppWindow.h)

target_link_libraries(AppointmentSchedulingSoftware Qt6::Widgets Qt::Sql)

The code I was running was working fine on linux but the moment I switched over to windows it started displaying this message. I do have QT, it's 6.10.1. So what could be the issue that is causing this?

Replies (15)