CMake cannot find Qt 6 when you build a Qt project on Ubuntu
Your error
Could not find a package configuration file provided by "Qt6" with any of the following names:3 more lines it can showFix it fast
Most common cause, 1 of 4The Qt 6 development package is not installed
Install the base development package, then configure again in a clean build folder so no failed result is reused.
sudo apt install qt6-base-dev
rm -rf build
cmake -B build -S .Short answer
CMake says it could not find a package configuration file provided by Qt6 when no Qt6Config.cmake lies on its search path. On Ubuntu 24.04 that means qt6-base-dev (Qt 6.4.2) is not installed, a module package such as qt6-declarative-dev is missing, the project wants a newer Qt than 6.4, or an installer copy of Qt sits outside CMAKE_PREFIX_PATH.
Which cause do you have?
Look for every Qt6Config.cmake on the machine, see which Qt version apt offers, and read the version and components the project asks for. Missing files, an old apt version or an unlisted installer path each match a different section here.
ls /usr/lib/x86_64-linux-gnu/cmake/Qt6/Qt6Config.cmake ~/Qt/*/gcc_64/lib/cmake/Qt6/Qt6Config.cmake 2>/dev/null
apt-cache policy qt6-base-dev
grep -n "find_package(Qt6" CMakeLists.txtThen find the line you see in this list and open its fix:
- 1The Qt 6 development package is not installed
No Qt6Config.cmake under /usr/lib/x86_64-linux-gnu/cmake/Qt6, and apt-cache policy shows qt6-base-dev as not installed - 2Qt 6 is found but one module's package is missing
Failed to find required Qt component "Quick", followed by an Expected Config file path that does NOT exist - 3The project needs a newer Qt than Ubuntu ships
is compatible with requested version "6.5", and the considered file is listed with version: 6.4.2 - 4Qt from the Online Installer is not on CMake's search path
Qt6Config.cmake exists under ~/Qt/<version>/gcc_64/lib/cmake/Qt6, yet plain cmake still cannot find Qt6
What does the error look like?
Could not find a package configuration file provided by "Qt6" with any of the following names:Add the installation prefix of "Qt6" to CMAKE_PREFIX_PATH or set "Qt6_DIR" to a directory containing one of the above files.Failed to find required Qt component "Quick".Could not find a configuration file for package "Qt6" that is compatible with requested version "6.5".
Cause 1 of 4
The Qt 6 development package is not installed
You seeNo Qt6Config.cmake under /usr/lib/x86_64-linux-gnu/cmake/Qt6, and apt-cache policy shows qt6-base-dev as not installed
Check
Could not find a package configuration file provided by Qt6, with nothing under /usr/lib/x86_64-linux-gnu/cmake/Qt6, means the Qt 6 development files are not on the system. CMake's message itself reminds you that a package with a separate development package must have it installed; on Ubuntu 24.04 that is qt6-base-dev from the universe repository, which ships Qt6Config.cmake plus the Gui and Widgets configs.
dpkg -S /usr/lib/x86_64-linux-gnu/cmake/Qt6/Qt6Config.cmakeFix
Install the base development package, then configure again in a clean build folder so no failed result is reused.
sudo apt install qt6-base-dev
rm -rf build
cmake -B build -S .Verify
dpkg -S names qt6-base-dev as the owner of Qt6Config.cmake, and the configure step finishes.
cmake -B build -S .Confirmed by packages.ubuntu.com
Cause 2 of 4
Qt 6 is found but one module's package is missing
You seeFailed to find required Qt component "Quick", followed by an Expected Config file path that does NOT exist
Check
Failed to find required Qt component with does NOT exist after the expected path means Qt6Config.cmake was found but the config for that module is not installed. Every Qt module brings its own config file; on Ubuntu 24.04 Qt6QuickConfig.cmake comes from qt6-declarative-dev, not from qt6-base-dev. The packages.ubuntu.com contents search finds the package for any other module's file.
ls /usr/lib/x86_64-linux-gnu/cmake/ | grep Qt6Fix
Install the development package that carries the missing module, then configure again.
sudo apt install qt6-declarative-dev
rm -rf build
cmake -B build -S .Verify
The Expected Config file path now exists, and find_package passes the COMPONENTS line.
ls /usr/lib/x86_64-linux-gnu/cmake/Qt6Quick/Qt6QuickConfig.cmakeConfirmed by packages.ubuntu.com
Cause 3 of 4
The project needs a newer Qt than Ubuntu ships
You seeis compatible with requested version "6.5", and the considered file is listed with version: 6.4.2
Check
Could not find a configuration file for package Qt6 that is compatible with the requested version means CMake did find Qt6Config.cmake but rejected its version. Ubuntu 24.04's own Qt 6 packages are version 6.4.2, so a find_package(Qt6 6.5 ...) line or anything newer refuses them.
grep -n "find_package(Qt6" CMakeLists.txtFix
Install a current Qt with the Qt Online Installer and point CMake at it (next cause). Lower the version in find_package only if you know the code uses nothing newer than 6.4.
Verify
CMake reports the Qt version from the installer copy and accepts it.
cmake -B build -S . -DCMAKE_PREFIX_PATH=$HOME/Qt/6.12.0/gcc_64Confirmed by packages.ubuntu.com
Cause 4 of 4
Qt from the Online Installer is not on CMake's search path
You seeQt6Config.cmake exists under ~/Qt/<version>/gcc_64/lib/cmake/Qt6, yet plain cmake still cannot find Qt6
Check
Could not find a package configuration file provided by Qt6 while an installer copy of Qt sits under ~/Qt means CMake was never told where that Qt lives. Qt's documentation names two ways: pass Qt6_ROOT or CMAKE_PREFIX_PATH pointing at the installation, or configure through qt-cmake, which hands the location to CMake itself.
ls -d ~/Qt/*/gcc_64Fix
Point CMake at the installation path. Qt's Linux page also expects build-essential and the OpenGL headers in libgl1-mesa-dev, which most distributions leave out, so install those for a GUI project.
sudo apt install build-essential libgl1-mesa-dev
rm -rf build
cmake -B build -S . -DCMAKE_PREFIX_PATH=$HOME/Qt/6.12.0/gcc_64Verify
The configure step finishes and the build links against the libraries under ~/Qt/6.12.0/gcc_64.
cmake --build buildConfirmed by doc.qt.io
How do I stop it coming back?
- Write the minimum Qt version into find_package and the README, so the team knows whether Ubuntu's 6.4.2 is enough.
- In CI, install Qt in a fixed path and pass CMAKE_PREFIX_PATH explicitly instead of relying on a developer's shell.
- List every Qt module the project uses in find_package COMPONENTS, and the matching -dev packages in the setup script.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.