我需要什么软件包来构建Qt 5和CMake应用程序?


37

我正在尝试在Ubuntu 13.10上构建sdrangelove,它需要Qt 5并使用CMake作为其构建系统。我需要安装什么软件包才能为其提供所需的文件?

有很多*qt5*软件包,我尝试安装有前途的软件包,但没有任何效果。我发现的所有讨论都可以使事情顺利进行,或者正在谈论编写CMake构建规则,而不是执行它们。我对Debian / Ubuntu包装的组织没有太多经验。

CMake Error at CMakeLists.txt:14 (find_package):
  By not providing "FindQt5Core.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Qt5Core", but
  CMake did not find one.

  Could not find a package configuration file provided by "Qt5Core"
  (requested version 5.0) with any of the following names:

    Qt5CoreConfig.cmake
    qt5core-config.cmake

  Add the installation prefix of "Qt5Core" to CMAKE_PREFIX_PATH or set
  "Qt5Core_DIR" to a directory containing one of the above files.  If
  "Qt5Core" provides a separate development package or SDK, be sure it has
  been installed.

Answers:


49

我在尝试编译KeePassX 2.0时偶然发现了这个问题。

帮助我的是使用apt-file搜索缺少的软件包:

例如运行以下命令:

apt文件搜索Qt5CoreConfig.cmake

返回以下包:

qtbase5-dev:/usr/lib/x86_64-linux-gnu/cmake/Qt5Core/Qt5CoreConfig.cmake

qtbase5-gles-dev:/usr/lib/x86_64-linux-gnu/cmake/Qt5Core/Qt5CoreConfig.cmake

然后可以使用apt或apt-get安装这些软件包,例如:

sudo apt安装qtbase5-dev


apt文件的快速参考(wiki.ubuntu.com/AptFile)。作品。
parasrish

21

我缺少的两件事:

  • 构建失败后,必须删除CMakeCache.txt(或简单地清除构建目录)。否则cmake即使已安装所需的软件包,也会报告相同的错误。

  • 提供*.cmake配置文件的软件包具有格式名称qt*5-dev,例如针对我的问题的错误qtcore5-dev


3
另一个选择是使用apt-file搜索丢失的软件包: apt-file search Qt5CoreConfig.cmake qtbase5-dev: /usr/lib/x86_64-linux-gnu/cmake/Qt5Core/Qt5CoreConfig.cmake qtbase5-gles-dev: /usr/lib/x86_64-linux-gnu/cmake/Qt5Core/Qt5CoreConfig.cmake
Francisco V.

@FranciscoV。您所写的应该得到答案。这样,也更容易阅读示例。
凯文·里德


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.