This application failed to start because it could not find or load the Qt platform plugin “xcb”
-
here is my stackoverflow question
this exist answer can not fix my question
In qt official example, I use following 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})
and I get
This application failed to start because it could not find or load the Qt platform plugin "xcb".
How to add "xcb" plugin to cmake?
update
I'm sure
find_library(xcb
find the lib "/media/roroco/disk750/Downloads/qtbase/plugins/platforms/libqxcb.so".update
when I addQApplication::addLibraryPath("/media/roroco/disk750/Downloads/qtbase/plugins");
and run again, I get:This application failed to start because it could not find or load the Qt platform plugin "xcb". Available platform plugins are: linuxfb, minimal, offscreen, xcb. Reinstalling the application may fix this problem.
update
I try to add "LD_LIBRARY_PATH" like following in main.cpp, but still get errorsetenv("LD_LIBRARY_PATH", "/media/roroco/disk750/Downloads/qtbase/lib:/media/roroco/disk750/Downloads/qtbase/plugins", 1); QApplication::addLibraryPath("/media/roroco/disk750/Downloads/qtbase/plugins");
-
here is my stackoverflow question
this exist answer can not fix my question
In qt official example, I use following 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})
and I get
This application failed to start because it could not find or load the Qt platform plugin "xcb".
How to add "xcb" plugin to cmake?
update
I'm sure
find_library(xcb
find the lib "/media/roroco/disk750/Downloads/qtbase/plugins/platforms/libqxcb.so".update
when I addQApplication::addLibraryPath("/media/roroco/disk750/Downloads/qtbase/plugins");
and run again, I get:This application failed to start because it could not find or load the Qt platform plugin "xcb". Available platform plugins are: linuxfb, minimal, offscreen, xcb. Reinstalling the application may fix this problem.
update
I try to add "LD_LIBRARY_PATH" like following in main.cpp, but still get errorsetenv("LD_LIBRARY_PATH", "/media/roroco/disk750/Downloads/qtbase/lib:/media/roroco/disk750/Downloads/qtbase/plugins", 1); QApplication::addLibraryPath("/media/roroco/disk750/Downloads/qtbase/plugins");
-
I had to troubleshoot this same xcb plugin problem when trying to run a third party app developed in Qt.
https://forum.qt.io/topic/64383/installed-app-cannot-find-or-load-plugin-xcb
And there are other threads in this forum if you just search 'xcb' ..
https://forum.qt.io/topic/64539/qt-5-5-app-deployment-on-ubuntu-14-04/4
As far as I understand (as a newcomer to Qt) LD_LIBRARY_PATH should just point to lib (not plugins as you have set)
In command line run .. qmake --version .. to get path to Qt lib.
When I run echo $LD_LIBRARY_PATH in command line I have
/opt/qt55/lib:/usr/lib/i386-linux-gnu/:/usr/lib/(/opt/qt55 is my custom installation of Qt 5.5.1).
You can get plugin debug information by running your app in command line
QT_DEBUG_PLUGINS=1 myappname
or setting QT_DEBUG_PLUGINS=1 in environment.
I solved my problem by
(a) adding a qt.conf file to same location as app binaries (/usr/bin)
[Paths]
Prefix= ../../opt/qt55
Translations=i18n
Libraries=lib
Plugins=plugins(b) adding Qt paths to ~/.profile
export PATH="/opt/qt55/bin":$PATH
export LD_LIBRARY_PATH="/opt/qt55/lib":${LD_LIBRARY_PATH}There might be some redundancy in above steps I took by trial and error.