Home > OS >  Qt6 Docker Ubuntu22.04 CMake Failed to find Qt component "Widgets"
Qt6 Docker Ubuntu22.04 CMake Failed to find Qt component "Widgets"

Time:09-21

I'm trying to build a small Qt6 application on a Docker container. It is running on Ubuntu:22.04. I have installed the qt6-base-dev package. Here is my small test app:

#include <QApplication>
#include <QWidget>
#include <iostream>

int main(int argc, char argv)
{
    QApplication app(argc, argv);

    QWidget widget;
    widget.setFixedSize(400, 400);

    QString helloString = "Hello from "   qgetenv("USER")   "!";
    widget.setWindowTitle(helloString);

    widget.show();

    return QApplication::exec();
}

And here is my CMakeList.txt:

cmake_minimum_required(VERSION 3.0)

project(testproj)

find_package(Qt6 REQUIRED COMPONENTS Widgets)

add_executable(testproj main.cpp)

target_link_libraries(testproj PRIVATE Qt6::Widgets)

But when my cmake is configuring this error appear:

CMake Error at CMakeLists.txt:5 (find_package):
  Found package configuration file:

    /usr/lib/x86_64-linux-gnu/cmake/Qt6/Qt6Config.cmake

  but it set Qt6_FOUND to FALSE so package "Qt6" is considered to be NOT
  FOUND.  Reason given by package:

  Failed to find Qt component "Widgets".

  Expected Config file at
  "/usr/lib/x86_64-linux-gnu/cmake/Qt6Widgets/Qt6WidgetsConfig.cmake" exists

The /usr/lib/x86_64-linux-gnu/cmake/Qt6Widgets/Qt6WidgetsConfig.cmake is existing.

I couldn't find anything online about this problem.

CodePudding user response:

I have installed libgl1-mesa-dev and libglvnd-dev and it worked perfectly !

  • Related