Important: Please read the Qt Code of Conduct -

Does Qt package contains static libs?

  • Hallo,
    I downloaded and installed qt-opensource-windows-x86-mingw492-5.5.1.exe
    In C:\Qt\5.5\mingw492_32\lib there are some .a files, like:

    12/10/2015  21:28            22.668 libQt5Concurrentd.a
    12/10/2015  21:20         4.040.156 libQt5Core.a
    12/10/2015  21:23         4.040.776 libQt5Cored.a
    12/10/2015  21:26           324.284 libQt5DBus.a
    12/10/2015  21:27           324.346 libQt5DBusd.a
    13/10/2015  02:06         1.635.122 libQt5Declarative.a
    13/10/2015  02:10         1.638.870 libQt5Declaratived.a
    13/10/2015  01:44         3.449.272 libQt5Designer.a
    13/10/2015  01:49            10.490 libQt5DesignerComponents.a
    13/10/2015  01:52            10.494 libQt5DesignerComponentsd.a
    13/10/2015  01:46         3.450.166 libQt5Designerd.a
    12/10/2015  21:31         5.377.422 libQt5Gui.a
    12/10/2015  21:34         5.393.772 libQt5Guid.a
    13/10/2015  01:41           219.536 libQt5Help.a
    13/10/2015  01:41           219.612 libQt5Helpd.a
    12/10/2015  22:58           962.506 libQt5Location.a
    12/10/2015  22:59           962.774 libQt5Locationd.a
    12/10/2015  22:30         1.742.548 libQt5Multimedia.a
    12/10/2015  22:32         1.743.268 libQt5Multimediad.a
    12/10/2015  22:33            58.144 libQt5MultimediaQuick_p.a 

    I think they are static Qt libraries, is that right?
    How can I use them? How can I build a statically linked application? I tried and tried, without success.
    There is only a qmake.exe file in the package and, according to me, it handles only dynamic libraries. So why include also .a files?

    best regards

  • Moderators

    Hi, welcome to the forum.

    This package does not contain static Qt libraries. The .a files are used to ease the dynamic linking. On Windows there are two ways to use dynamic libraries.

    The first one is by calling LoadLibrary (or using QLibrary that wraps it) at runtime. It's not convenient because you need to resolve all the symbols manually this way - lots of pointless work with a huge library like Qt.

    The other way (preferable and used here) is to link to a library that will load and resolve the shared library (dll) at runtime for you. The .a files you listed are just that. You link to them and you still need the dlls at runtime.

    As for how you use them: When you create a project in Qt Creator , in your .pro file you add the modules you need in the QT variable, for example: QT += core gui widgets network. After that you just run qmake (Build->Run qmake). This handles all the linking to the right .a files for you.

    To have a static build (without the dlls) of Qt you need to build it manually from source package. Be aware that there are licensing restrictions for the open-sourced version of Qt when linking statically.