【问题标题】:This application failed to start because it could not find or load the Qt platform plugin "xcb"此应用程序无法启动,因为它无法找到或加载 Qt 平台插件“xcb”
【发布时间】:2016-06-10 11:24:11
【问题描述】:

这个exist answer 无法解决我的问题

在 qt official example 中,我使用以下 CMakeLists.txt

SET(CMAKE_PREFIX_PATH /media/roroco/disk750/Downloads/qtbase)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
find_package(Qt5Widgets)
find_library(xcb NAMES qxcb PATHS /media/roroco/disk750/Downloads/qtbase/plugins/platforms)
add_executable(systray main.cpp window.cpp systray.qrc)
target_link_libraries(systray Qt5::Widgets ${xcb})

我得到了

This application failed to start because it could not find or load the Qt platform plugin "xcb".

如何在cmake中添加“xcb”插件?

更新

我确定find_library(xcb 找到了库“/media/roroco/disk750/Downloads/qtbase/plugins/platforms/libqxcb.so”。

【问题讨论】:

  • 如果你在 Ubuntu 或 Debian 上,xcb 插件是/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so。它是由libqt5gui5 包安装的,所以它应该在那里。

标签: c++ qt user-interface


【解决方案1】:

当我ldd /media/roroco/disk750/Downloads/qtbase/plugins/platforms/libqxcb.so时,有一些deps显示“未找到”,所以我猜是这个原因

我找到的临时解决方案是添加

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${qt_rt}/lib
export QT_QPA_PLATFORM_PLUGIN_PATH=${qt_rt}/plugins
export QT_QPA_FONTDIR=${qt_rt}/lib/fonts

到~/.bashrc 和源~/.bashrc,重新打开编辑器再试一次。

但这里有个问题,当我在 CMakeLists.txt 中使用 set(ENV{LD_LIBRARY_PATH} path/to/qtbase/lib) 而不是 ~/.bashrc 中的 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:path/to/qtbase/lib 时,它不起作用,它仍然会引发错误,如果有人知道原因,请创建新答案对于这个问题,我认为在 cmake 中更改 env 是更好的方法

【讨论】:

  • 不要发布附加信息作为答案。更好地编辑或评论问题消息。
猜你喜欢
  • 2015-06-06
  • 2017-07-24
  • 2014-04-11
  • 2014-10-01
  • 2019-07-26
  • 1970-01-01
  • 2018-06-07
  • 1970-01-01
  • 2016-01-08
相关资源
最近更新 更多