Planned maintenance has been done but it did not solve the problem. So work will continue on this and a new time for trying updates will be announced asap.

Building Qt as a static



  • I am trying to build Qt, on my Fedora 21 x64, as a static libraries so I can build my application to link against the static libraries. I have followed the instructions on this blog :https://wiki.qt.io/Building_Qt_5_from_Git, and have successfully compiled the qt source libraries. I tried to build an application from the examples directory and everything compiled fine. But I get the following error when trying to run the application:

    This application failed to start because it could not find or load the Qt platform plugin "xcb".
    Reinstalling the application may fix this problem.

    I have already installed the xcb-util package.

    #yum install xcb-util
    Loaded plugins: langpacks
    Package xcb-util-0.4.0-2.fc21.x86_64 already installed and latest version
    Nothing to do

    [gmahan@localhost platforms]$ pwd
    /home/gmahan/qt5/qtbase/plugins/platforms
    [gmahan@localhost platforms]$ ls
    libqlinuxfb.a libqminimal.a libqoffscreen.a libqxcb.a libqlinuxfb.prl libqminimal.prl libqoffscreen.prl libqxcb.prl

    I'm not sure how to proceed. I haven't found how to resolve this after reading a few similar problems.


  • Lifetime Qt Champion

    Hi,

    Static plugins need special handling, see Q_IMPORT_PLUGIN for more information.



  • @SGaist Thanks for pointing this out.

    After reading a bit I added the following to the .pro and the main.cpp file.

    TEMPLATE = app
    LIBS += /home/gmahan/qt5/qtbase/plugins/platforms/libqxcb.a
    

    In main.cpp, I added the following:

     #include <QApplication>
     #include <QtPlugin>
     #include "mapzoom.h"
    
     Q_IMPORT_PLUGIN(qxcb)
    

    Gave me the following error in make:

    /home/gmahan/qt5/qtbase/examples/embedded/lightmaps/main.cpp:46: undefined reference to `qt_static_plugin_qxcb()

    But according to http://doc.qt.io/qt-5/plugins-howto.html#static-plugins, all I need is

    QTPLUGIN += qxcb
    

    The above line gave me the following warning :

    Project WARNING: Redundant entries in QTPLUGIN: qxcb


  • Lifetime Qt Champion

    Aren't you missing a -l in your LIBS line ?



  • @SGaist Didn't think that was necessary for static libraries, works in my other project without the -L for static libs, but I'll try it nevertheless.


  • Lifetime Qt Champion

    not -L -l. -L is to add entries to the folder list the linker will search into


Log in to reply