此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".
如何添加" xcb"插件到cmake?
更新
我确定find_library(xcb
找到了lib" /media/roroco/disk750/Downloads/qtbase/plugins/platforms/libqxcb.so"。
答案 0 :(得分:0)
当我ldd /media/roroco/disk750/Downloads/qtbase/plugins/platforms/libqxcb.so
时,有一些代表显示"未找到",所以我猜其原因
我发现的临时解决方案是添加
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和source~ / .bashrc,重新打开编辑器再试一次。
但是问题是,当我在〜/ .bashrc中使用CMakeLists.txt中的set(ENV{LD_LIBRARY_PATH} path/to/qtbase/lib)
代替export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:path/to/qtbase/lib
时,它不起作用,如果有人知道,它仍会引发错误原因,请为这个问题创建新的答案,我认为在cmake中更改env是更好的方式