c++qtqt5static-librariesstatic-linking

Static libraries in Qt 5.14 MinGW toolchain? (default Qt installation)


Just now I noted that the MinGW Toolchain that comes with the default Qt installation, at least Qt 5.14, comes with a lib directory with libQt5*.a files. Are those files static libraries?

I think so because:

  1. They have a size similar to the ones that I get when I compile Qt statically for release.
  2. $file ./libQt5Core.a outputs ./libQt5Core.a: current ar archive, which is the same that it outputs for the statically compiled ones.

If indeed they're static libraries, how can I tell QMake (for example editing the .pro file) to link to those instead of linking to the shared ones?

Windows screenshot of Qt static libs


Solution

  • Are those files static libraries?

    No. They are not static. Qt’s default online installer provides only shared libraries. That *.a files are so-called import libraries.

    Import library is an .a or .lib library, but it only contains bit of information needed to tell the linker/OS how your program interacts with the dll’s.

    If you need Qt static windows build for some reasons, you have some options:

    With vcpkg you can create custom MinGW triplet if you need MinGW for some reason. But I suggest you stick with MSVC.