默认安装前缀 QT5 / QT5 Widgets Ubuntu

默认安装前缀 QT5 / QT5 Widgets Ubuntu

我有一个 CMake 项目。我正在尝试从 QT4 切换到 QT5。

 find_package(QT5Widgets REQUIRED) EDIT HERE IS A TYPO problem solved (Qt5... instead of QT5...)

已经给了我

By not providing "FindQT5Widgets.cmake" in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by
"QT5Widgets", but CMake did not find one.
Could not find a package configuration file provided by "QT5Widgets" with
any of the following names:

QT5WidgetsConfig.cmake
qt5widgets-config.cmake

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

我确实通过以下方式安装了 Ubuntu 软件包:

  sudo apt-get install qt5-default

虽然我知道文件 QT5WidgetsConfig.cmake 包含在

/usr/lib/x86_64-linux-gnu/cmake/Qt5Widgets/

我不知道如何将“QT5Widgets_DIR”设置为此文件夹。无论如何,这都是我不喜欢的解决方案,因此我想将 CMAKE_PREFIX_PATH 设置为安装文件夹。

但我不知道我需要链接到哪里。到目前为止尝试过:

set (CMAKE_PREFIX_PATH "/usr/lib/x86_64-linux-gnu/cmake/Qt5Widgets/")

同样的错误。

我尝试通过以下方式获取信息

dpkg -L qt5-default

打印

/usr
/usr/share
/usr/share/doc
/usr/share/doc/qt5-default
/usr/share/doc/qt5-default/copyright
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/qtchooser
/usr/share/doc/qt5-default/LGPL_EXCEPTION.txt
/usr/share/doc/qt5-default/changelog.Debian.gz
/usr/lib/x86_64-linux-gnu/qtchooser/default.conf

我应该在哪里/如何寻找正确的道路?

问候 Jan

答案1

对于 Linux,

下载并安装qt5从他们的网站

CMAKE_PREFIX_PATH然后改变

$ CMAKE_PREFIX_PATH="{Path of gcc_64 under recently installed qt folder, example: $HOME/qt5/5.7/gcc_64}"

答案2

您和我一样链接到了错误的地方。您必须在安装 Qt 的位置设置 CMAKE_PREFIX_PATH。在我的情况下,它是:

set(CMAKE_PREFIX_PATH $ENV{HOME}/Qt/5.5/gcc_64)

其中 $ENV{HOME} 是主目录

希望它能帮助你。

相关内容