如何修复 Ubuntu 上的 CMake 'Failed to find Qt component "Core5Compat"'

问题:

当尝试编译你的 CMake 项目时,你会看到类似这样的错误消息

qt_core5compat_error.txt
CMake Error at cMake/FreeCAD_Helpers/SetupQt.cmake:33 (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 "Core5Compat".

  Expected Config file at
  "/usr/lib/x86_64-linux-gnu/cmake/Qt6Core5Compat/Qt6Core5CompatConfig.cmake"
  does NOT exist



Call Stack (most recent call first):
  CMakeLists.txt:82 (include)

解决方案

install_libqt6core5compat6_dev.sh
sudo apt -y install libqt6core5compat6-dev

在 Ubuntu 22.04 上测试


Check out similar posts by category: CMake, Linux