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

Error running statically-linked application... Could not find the Qt platform plugin "xcb"



  • I've read a bunch of posts on this subject, but I'm not sure, yet, what the solution is.

    I have a subdirs project name, InPlantScanner, that I created with a standard install of Qt on Ubuntu 16.04 lts. It runs fine when I run it from Qt creator and the command line. Now I need to get it ready for deployment to the destination computer. I don't want to install Qt on the computer (though I could) to keep the maintenance more simple. When I update the application, it updates everything needed.

    So, I'm following the instructions at: https://doc.qt.io/qt-5/linux-deployment.html for x11 deployment. I had some challenges and received help in the forums getting the statically-linked Qt setup (https://forum.qt.io/topic/104112/clarification-of-path-to-qt-in-qt-documentation/2)

    Now, I have built my application with the 5.12.4, statically-linked Qt. When I run my application (./IPSgui), I get some errors:

    QFactoryLoader::QFactoryLoader() ignoring "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3" since plugins are disabled in static builds
    
    qt.qpa.plugin, Could not find the Qt platform plugin "xcb" in ""
    

    From some of the posts I read, I thought I should re-compile the Qt-5124 with the -qt-xcb option, but that didn't work.

    $ ../Qt/5.12.4/Src/configure -static -prefix ~/qt-5124 -qt-xcb
    
    ERROR: Feature 'xcb' was enabled, but the pre-condition 'features.thread && features.xkbcommon && libs.xcb' failed.
    

    I could keep adding dependencies to the compilation, but I'm not sure what to specify to include features.thread and features.xkbcommon.

    I have 2 questions:

    1. Will continuting to add the dependencies like I started with -qt-xcb work eventually?
    2. Is there a better path?


  • @Daniel-Williams do you have X11 development libraries and headers installed in the machine where you try to build static Qt?



  • @Pablo-J-Rogina I had run the apt-get install previously to make sure they were installed:

     sudo apt-get install libx11-dev
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    libx11-dev is already the newest version (2:1.6.3-1ubuntu2.1).
    

    They were installed previously. The part of you reply "where you try to build static Qt" is not familiar to me. Do I need to copy them from the base install location somewhere?


  • Lifetime Qt Champion

    Hi,

    @Daniel-Williams said in Error running statically-linked application... Could not find the Qt platform plugin "xcb":

    features.xkbcommon

    Do you have the xkbcommon development package installed ?



  • @SGaist How do I tell if I have xkbcommon installed? I tried sudo apt-get install xkbcommon and received an error "unable to locate packate xkbcommon."



  • @SGaist I was able to run sudo apt-get install libxkbcommon-dev and it installed the package.


  • Lifetime Qt Champion

    Good, did that solve your build problem ?



  • @SGaist Unfortunately not. I also expanded that with:

    sudo apt install '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev

    In the ~/qt-5124-build/config.log file, I see some errors, but I'm not sure how to resolve the errors. I tried to attach the file, but I don't have privileges for that.

    Sample error messages:

    
    executing config test c++1z
    + cd /home/inplant/qt-5124-build/config.tests/c++1z && /home/inplant/qt-5124-build/qtbase/bin/qmake "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += static use_gold_linker warn_off console single_arch" /home/inplant/qt-5124-build/config.tests/c++1z
    + cd /home/inplant/qt-5124-build/config.tests/c++1z && MAKEFLAGS= /usr/bin/make
    > g++ -c -pipe -O2 -std=gnu++1z -w -fPIC  -I. -I/home/inplant/Qt/5.12.4/Src/qtbase/mkspecs/linux-g++ -o main.o main.cpp
    > main.cpp:8:19: fatal error: variant: No such file or directory
    > compilation terminated.
    > Makefile:167: recipe for target 'main.o' failed
    > make: *** [main.o] Error 1
    
    Trying source 2 (type inline) of library dbus ...
    None of [libdbus-1.so libdbus-1.a] found in [] and global paths.
      => source produced no result.
    test config.qtbase.libraries.dbus FAILED
    
    Trying source 1 (type inline) of library libudev ...
    None of [libudev.so libudev.a] found in [] and global paths.
      => source produced no result.
    test config.qtbase.libraries.libudev FAILED
    


  • I thought I'd give some more detail of what I'm doing in case I'm missing a step:

    Linux ubuntu 4.15.0-52-generic #56~16.04.1-Ubuntu SMP Thu Jun 6 12:03:31 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux running in a VMWare virtual machine on a windows 10 computer.

    I originally installed Qt open source. It installed a kit (5.12.1 and I later upgraded to 5.12.4).
    The kit I have is located at ~/Qt/5.12.4.

    That was all I had while I was developing the subdirs project (InPlantScanner). When I build using that kit, it builds
    to ~/scannerRD/builds/release/InPlantScanner. Using this application I can run the program just fine. All of
    the necessary libraries are on the system and the application works great.

    Now, I'm ready to deploy the appliation to a physical server running the same version of linux. For simplicity,
    I decided to deploy it as a statically-linked application. I want to be able to take the build directory,
    copy it to the destination server and have it run.

    I followed these directions:
    https://doc.qt.io/qt-5/linux-deployment.html

    cd ~
    mkdir qt-5124
    mkdir qt-5124-build
    cd ~/qt-5124-build
    ../Qt/5.12.4/Src/configure -static -prefix ~/qt-5124

    make -j 4 #make the build
    make install #install to ~/qt-5124

    #After several hours, the install was complete.
    #I opened the subdirs project, InPlantScanner, in Qt creator. I added a new kit with the statically-linked
    #version of Qt. I set the project to build to ~/scannerRD/builds/staticallylinked/release/InPlantScanner

    #I re-built the application in Qt creator and it built successfully.

    cd ~/scannerRD/builds/staticallylinked/release/InPlantScanner/IPSguid
    ./IPSgui

    #I then look in the logs and see the error I listed at the beginning of this post.

    #There are some errors in the config.log file. But, I have no idea how to fix them.
    #I'm attaching the latest config.log file.

    #For Example, I see this error on line 175:
    175 > g++ -c -pipe -O2 -std=gnu++1z -w -fPIC -I. -I/home/inplant/Qt/5.12.4/Src/qtbase/mkspecs/linux-g++ -o main.o main.cpp
    176 > main.cpp:8:19: fatal error: variant: No such file or directory
    177 > compilation terminated.
    178 > Makefile:167: recipe for target 'main.o' failed
    179 > make: *** [main.o] Error 1
    180 test config.qtbase.tests.c++1z FAILED

    #I don't know what main is in relation to the Qt source code. How do I fix that.



  • This is what I ultimately had to do to resolve the issue:

    sudo apt install libxkbcommon-dev
    sudo apt install '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev

    ../Qt/5.12.4/Src/configure -static -prefix ~/qt-5124 -system-xcb -recheck-all

    Note:
    I had a build directory that I used for an interim build location: ~/qt-5124-build. In that directory, there were two very useful file:
    config.log
    config.summary


Log in to reply