2

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".

Community
  • 1
  • 1
iufachajov
  • 233
  • 2
  • 8
  • If you're on Ubuntu or Debian, the xcb plugin is `/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so`. It's installed by the `libqt5gui5` package, so it should be there. – Velkan Feb 29 '16 at 07:30

1 Answers1

0

when I ldd /media/roroco/disk750/Downloads/qtbase/plugins/platforms/libqxcb.so, there are some deps show "not found", so I guess the reason it's that

the temp solution what i find is add

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

to ~/.bashrc and source ~/.bashrc, reopen editor and try again.

but here is question, when i use set(ENV{LD_LIBRARY_PATH} path/to/qtbase/lib) in CMakeLists.txt instead of export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:path/to/qtbase/lib in ~/.bashrc, it doesn't work, it still raise error, if someone know the reason, please create new answer for this question, I think change env in cmake is better way

iufachajov
  • 233
  • 2
  • 8