Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt5 with OpenGL (on Raspberry Pi 0) getting error QXcbConnection: Could not connect to display Could not connect to any X display



  • I have successfully cross-compiled Qt5.15.0 with HW accelerated OpenGL (eglfs) so that Qt apps can run without x11. I know that I was able to cross-compile and install qt5.15.0 successfully on pi0 because I am able to cross-compile and deploy remotely non GUI application from QtCreator.

    However when I run GUI application (for example qopenglwidget example project that comes with qt source code), I get the following error:

    qt.qpa.screen: QXcbConnection: Could not connect to display 
    Could not connect to any X display.
    

    As the application compiled without any error I assume that the problem comes error while linking to some dynamic library. Has any had similar issues and does anyone know how to fix this ? The following observation may be useful for answering my query

    • After installing qt5 library I have updated ldconfig by running:
    echo /usr/local/qt5pi/lib | sudo tee /etc/ld.so.conf.d/qt5pi.conf
    sudo ldconfig
    
    • When configuring Qt5 for install I had put the option -opengl option and I had obtained the following options (only relevant ones shown here) :
    Desktop OpenGL ....................... no
    OpenGL ES 2.0 ........................ yes
    
    EGLFS .................................. yes
      EGLFS Raspberry Pi ................... yes
    
    X11 specific:
      XLib ................................. no
      XCB Xlib ............................. no
      EGL on X11 ........................... no
      xkbcommon-x11 ........................ no
    
    • Raspberry Pi zero W is running : Raspbian Buster (Linux kernel 5.


  • @sierdzio said in Qt5 with OpenGL (on Raspberry Pi 0) getting error QXcbConnection: Could not connect to display Could not connect to any X display:

    @glamis said in Qt5 with OpenGL (on Raspberry Pi 0) getting error QXcbConnection: Could not connect to display Could not connect to any X display:

    How can I force it to use my version of Qt5 ?

    Set the LD path before running (does not require recompilation):

    export LD_LIBRARY_PATH=/path/to/your/qt
    ./yourAppBinary
    

    Or you can link with rpath (does require recompilation).

    Thanks for the suggestion. Modifying LD_LIBRARY_PATH did indeed work. Addiotionaly I had to add the currect user to video group (and login/logout to apply changes):

    usermod -aG video $USER
    

    I will recompile with -rpath option to fix this issue permanently.


  • Moderators

    • are you running with your Qt or the one built-into Raspbian (check with ldd)
    • you can force correct platform plugin using command line switch: ./yourAppBinary -platform eglfs


  • @sierdzio said in Qt5 with OpenGL (on Raspberry Pi 0) getting error QXcbConnection: Could not connect to display Could not connect to any X display:

    ldd

    Thanks for the suggestion. Indeed the application is using the built-in qt5 and not rhe one I used:

    dietpi@pifotoframe:~$ ldd qopenglwidget 
    	/usr/lib/arm-linux-gnueabihf/libarmmem-${PLATFORM}.so => /usr/lib/arm-linux-gnueabihf/libarmmem-v6l.so (0xb6f95000)
    	libQt5Widgets.so.5 => /usr/lib/arm-linux-gnueabihf/libQt5Widgets.so.5 (0xb6a39000)
    	libQt5Gui.so.5 => /usr/lib/arm-linux-gnueabihf/libQt5Gui.so.5 (0xb65b9000)
    	libQt5Core.so.5 => /usr/lib/arm-linux-gnueabihf/libQt5Core.so.5 (0xb613f000)
    	libGLESv2.so => /opt/vc/lib/libGLESv2.so (0xb611a000)
    	libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0xb60f0000)
    	libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0xb5fa9000)
    	libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0xb5f27000)
    	libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0xb5efa000)
    	libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb5dac000)
    	/lib/ld-linux-armhf.so.3 (0xb6fa8000)
    	libpng16.so.16 => /usr/lib/arm-linux-gnueabihf/libpng16.so.16 (0xb5d70000)
    	libharfbuzz.so.0 => /usr/lib/arm-linux-gnueabihf/libharfbuzz.so.0 (0xb5c72000)
    	libz.so.1 => /lib/arm-linux-gnueabihf/libz.so.1 (0xb5c47000)
    	libatomic.so.1 => /usr/lib/arm-linux-gnueabihf/libatomic.so.1 (0xb5c2e000)
    	libicui18n.so.63 => /usr/lib/arm-linux-gnueabihf/libicui18n.so.63 (0xb59e0000)
    	libicuuc.so.63 => /usr/lib/arm-linux-gnueabihf/libicuuc.so.63 (0xb585a000)
    	libpcre2-16.so.0 => /usr/lib/arm-linux-gnueabihf/libpcre2-16.so.0 (0xb57de000)
    	libdouble-conversion.so.1 => /usr/lib/arm-linux-gnueabihf/libdouble-conversion.so.1 (0xb57ba000)
    	libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0xb57a7000)
    	libglib-2.0.so.0 => /usr/lib/arm-linux-gnueabihf/libglib-2.0.so.0 (0xb5697000)
    	libEGL.so => /opt/vc/lib/libEGL.so (0xb565e000)
    	libbcm_host.so => /opt/vc/lib/libbcm_host.so (0xb5634000)
    	libvchiq_arm.so => /opt/vc/lib/libvchiq_arm.so (0xb561e000)
    	libvcos.so => /opt/vc/lib/libvcos.so (0xb5605000)
    	librt.so.1 => /lib/arm-linux-gnueabihf/librt.so.1 (0xb55ee000)
    	libfreetype.so.6 => /usr/lib/arm-linux-gnueabihf/libfreetype.so.6 (0xb554b000)
    	libgraphite2.so.3 => /usr/lib/arm-linux-gnueabihf/libgraphite2.so.3 (0xb551a000)
    	libicudata.so.63 => /usr/lib/arm-linux-gnueabihf/libicudata.so.63 (0xb3b1c000)
    	libpcre.so.3 => /lib/arm-linux-gnueabihf/libpcre.so.3 (0xb3aa5000)
    

    How can I force it to use my version of Qt5 ?

    I have already tried

    ./yourAppBinary -platform eglfs
    

    But I'm getting the following error :

    dietpi@pifotoframe:~$ ./qopenglwidget -platform eglfs
    Could not open display
    Aborted
    

  • Moderators

    @glamis said in Qt5 with OpenGL (on Raspberry Pi 0) getting error QXcbConnection: Could not connect to display Could not connect to any X display:

    How can I force it to use my version of Qt5 ?

    Set the LD path before running (does not require recompilation):

    export LD_LIBRARY_PATH=/path/to/your/qt
    ./yourAppBinary
    

    Or you can link with rpath (does require recompilation).



  • @sierdzio said in Qt5 with OpenGL (on Raspberry Pi 0) getting error QXcbConnection: Could not connect to display Could not connect to any X display:

    @glamis said in Qt5 with OpenGL (on Raspberry Pi 0) getting error QXcbConnection: Could not connect to display Could not connect to any X display:

    How can I force it to use my version of Qt5 ?

    Set the LD path before running (does not require recompilation):

    export LD_LIBRARY_PATH=/path/to/your/qt
    ./yourAppBinary
    

    Or you can link with rpath (does require recompilation).

    Thanks for the suggestion. Modifying LD_LIBRARY_PATH did indeed work. Addiotionaly I had to add the currect user to video group (and login/logout to apply changes):

    usermod -aG video $USER
    

    I will recompile with -rpath option to fix this issue permanently.




Log in to reply