Search code examples
c++qtcross-platformraspbian

C++ Qt 5.10 Cross compiling for Raspberry PI 3 This application failed to start because it could not find or load the Qt platform plugin "xcb" in ""


i have tried to cross compile qt 5.10 for my Rasperry pi 3. I had used the following guide to finish the task: Step by step to compile

I have used the following command to do this:

sudo ./configure -release -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=~/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-
gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- -sysroot ~/raspi/sysroot -opensource -confirm-license -make libs -prefix /usr/local/qt5pi -extprefix ~/raspi/qt5pi -hostprefix ~/raspi/qt5 -v -no-use-gold-linker

There was no Problem to do this. Now i have tryed to run the example qopenglwidget but i get the following error message:

sudo ./qopenglwidget

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

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, >vnc, xcb. Reinstalling the application may fix this problem.

Aborted

I have tried the ldd on the application and get hte following output:

ldd qopenglwidget
    linux-vdso.so.1 (0x7e9a4000)
    /usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76f77000)
    libQt5Widgets.so.5 => /usr/lib/arm-linux-gnueabihf/libQt5Widgets.so.5 (0x76a11000)
    libQt5Gui.so.5 => /usr/lib/arm-linux-gnueabihf/libQt5Gui.so.5 (0x765eb000)
    libQt5Core.so.5 => /usr/local/qt5pi2/lib/libQt5Core.so.5 (0x760b9000)
    libGLESv2.so => /opt/vc/lib/libGLESv2.so (0x76094000)
    libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0x7606b000)
    libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0x75f23000)
    libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x75ea4000)
    libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0x75e77000)
    libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x75d38000)
    /lib/ld-linux-armhf.so.3 (0x76f8d000)
    libharfbuzz.so.0 => /usr/lib/arm-linux-gnueabihf/libharfbuzz.so.0 (0x75ca1000)
    libz.so.1 => /lib/arm-linux-gnueabihf/libz.so.1 (0x75c7a000)
    libpng16.so.16 => /usr/lib/arm-linux-gnueabihf/libpng16.so.16 (0x75c40000)
    libdouble-conversion.so.1 => /usr/lib/arm-linux-gnueabihf/libdouble-conversion.so.1 (0x75c1e000)
    libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x75c0b000)
    libgthread-2.0.so.0 => /usr/lib/arm-linux-gnueabihf/libgthread-2.0.so.0 (0x75bf9000)
    libglib-2.0.so.0 => /lib/arm-linux-gnueabihf/libglib-2.0.so.0 (0x75af1000)
    libEGL.so => /opt/vc/lib/libEGL.so (0x75ab8000)
    libbcm_host.so => /opt/vc/lib/libbcm_host.so (0x75a91000)
    libvchiq_arm.so => /opt/vc/lib/libvchiq_arm.so (0x75a7b000)
    libvcos.so => /opt/vc/lib/libvcos.so (0x75a61000)
    librt.so.1 => /lib/arm-linux-gnueabihf/librt.so.1 (0x75a4a000)
    libfreetype.so.6 => /usr/lib/arm-linux-gnueabihf/libfreetype.so.6 (0x759af000)
    libgraphite2.so.3 => /usr/lib/arm-linux-gnueabihf/libgraphite2.so.3 (0x7597c000)
    libpcre.so.3 => /lib/arm-linux-gnueabihf/libpcre.so.3 (0x75903000)

I have tried to set the LDD_LIBRARY_PATH to /usr/local/qt5pi2/platforms but it don't work.

Please have someone any idea what i have done wrong?

After i have add the QT_QPA_PLATFORM_PLUGIN_PATH i get the following error:

./qopenglwidget This application failed to start because it could not find or load the Qt >platform plugin "xcb" in "/usr/local/qt5pi/plugins/platforms/".

Available platform plugins are: eglfs (from >/usr/local/qt5pi/plugins/platforms/), linuxfb (from >/usr/local/qt5pi/plugins/platforms/), minimal (from >/usr/local/qt5pi/plugins/platforms/), minimalegl (from >/usr/local/qt5pi/plugins/platforms/), offscreen (from >/usr/local/qt5pi/plugins/platforms/), vnc (from >/usr/local/qt5pi/plugins/platforms/), xcb (from >/usr/local/qt5pi/plugins/platforms/), eglfs, linuxfb, minimal, minimalegl, >offscreen, vnc.

Reinstalling the application may fix this problem. Aborted

After the help of p-a-o-l-o (thank you very much)i have export the

QT_QPA_PLATFORM_PLUGIN_PATH 

and after that i have done the following:

export LD_LIBRARY_PATH=/usr/local/qt5pi/lib
sudo ldconfig

Now it works for me.

I someone else will try to crosscompile qt 5.10 for the raspberry pi it is important to start with a blank System (Raspbian stretch) and do only the thing in the guide above.


Solution

  • I think the path to the plugin is empty, try setting it with

    export QT_QPA_PLATFORM_PLUGIN_PATH=/usr/lib/plugins/platforms
    

    before launching your application (the path I provided is just an example, though).

    If this doesn't solve the issue, the xcb plugin could not be loaded (it could be an x server issue on your target device). Try loading a different plugin exporting QT_QPA_PLATFORM before launch, e.g.:

    export QT_QPA_PLATFORM=eglfs
    

    or

    export QT_QPA_PLATFORM=minimalegl