Qt5.11.1 Windowsx64 Static Build. Why Is It Looking For 'Plug Ins'?



  • I am spec'ing out Qt for the company I work for.
    It is clear that if we decide to use it we will need to make some modifications to it.
    (Yes I understand all about the liscensing).

    We also will not want to build applications dynamically (shared, .Dll's) but rather will want to statically link our applications to static Qt libraries.

    Our targets are Windows 10 and Linux.
    Currently the applications in question are:

    • Windows 10, native Win32
    • Linux, GTK+

    Qt 5.11.1 (Windows x64)
    I am working with Visual Studio 2017

    1st thing is I created a Qt application linking to the .Dll's that where installed from the Qt installation (Dynamic, 'Shared'). The application links and executes just fine.

    Now I built the Qt static libraries:
    1.) configure -platform win32-msvc2017 -static -static-runtime -release -ltcg -optimize-size -no-pch -prefix c:\Source\Qt\Qt5111\Static -skip webengine -nomake tools -nomake tests -nomake examples
    2.) Ran nmake > MyLog.txt.

    It built the static libraries just fine. MyLog.txt contains no errors.
    (noted warning are present as expected from non-use of string safe function,type casts,...)

    I built the Qt application linking to the static libraries that where created.
    It links fine, no errors, no warnings.
    Libs:
    C:\Source\Qt\Qt5.11.1\5.11.1\Src\qtbase\lib\Qt5Core.lib
    C:\Source\Qt\Qt5.11.1\5.11.1\Src\qtbase\lib\Qt5Gui.lib
    C:\Source\Qt\Qt5.11.1\5.11.1\Src\qtbase\lib\Qt5Widgets.lib
    C:\Source\Qt\Qt5.11.1\5.11.1\Src\qtbase\lib\qtmain.lib
    C:\Source\Qt\Qt5.11.1\5.11.1\Src\qtbase\lib\qtpcre2.lib
    C:\Source\Qt\Qt5.11.1\5.11.1\Src\qtbase\lib\qtharfbuzz.lib
    C:\Source\Qt\Qt5.11.1\5.11.1\Src\qtbase\lib\qtlibpng.lib
    C:\Source\Qt\Qt5.11.1\5.11.1\Src\qtbase\plugins\platforms\qwindows.lib

    Issues:
    I run the QtApplication:

    • qt.qpa.plugin: Could not find the Qt platform plugin "windows" in ""
    • This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
    • Application crashes.

    NOTE: I am very well aware of the environment variable QT_QPA_PLATFORM_PLUGIN_PATH and qwindows.dll (see below), but I do not understand why Qt is looking for any .Dll's since I am statically linked.

    With all that said my question is not really about the above issues, but rather why is Qt attempting to load any 'Plug Ins' at all? Besides the standard Windows and Msvc .Dll's I do not see why Qt thinks that additional dynamically linked libraries (PlugIns) are required.
    Why is it even looking for qwindows.dll (that in fact resides in C:\Source\Qt\Qt5.11.1\5.11.1\msvc2017_64\plugins\platforms)?
    My Qt application is statically linked to the static qwindows.lib that was built.

    All of the suggestions and 'answers' to questions that sort of look like mine are red-herrings:

    • QT_QPA_PLATFORM_PLUGIN_PATH should not be applicable as I am statically linked.
    • All answers such as 'put this file here' are not applicable.
    • windeployqt is not applicable as I am statically linked (i.e. it will not find any Qt dependancies).

    Though I have not created a static debug version of Qt, the following is clearly being called:
    Qt5\Qt5.11.1\5.11.1\Src\qtbase\src\gui\kernel\qguiapplication.cpp

    • void QGuiApplicationPrivate::createPlatformIntegration().
      -- Which calls static void init_platform(const QString &pluginNamesWithArguments, const QString &platformPluginPath, const QString &platformThemeName, int &argc, char **argv)

    I do not understand why the above two functions are even being called!

    Any direction would be greatly appreciated.

    QT_QPA_PLATFORM_PLUGIN_PATH
    For kicks (though I am convinced this has nothing to do with my issue) I set
    QT_QPA_PLATFORM_PLUGIN_PATH To the location of the qwindows.dd even though this is from the dynamic build (i.e. the install).

    I run the QtApplication:

    • qt.qpa.plugin: Could not find the Qt platform plugin "windows" in "C:\Source\Qt\Qt5.11.1\5.11.1\msvc2017_64\plugins\platforms"
    • This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
    • Application crashes.

    Thanks in advance.



  • Hi, think you need to import the plugins so that they're linked into your .exe file, see more here



  • Thanks for the 'hint' hskoglund.
    I am not using the Qt system to do my builds (.pro, .pri, cmake) I am using Visual Studio 2017.

    So I added Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin); to my main().
    I then needed to add additional libraries to my linkage. My linkage now looks like this:
    C:\Source\Qt\Qt5.11.1\5.11.1\Src\qtbase\lib\Qt5Core.lib
    C:\Source\Qt\Qt5.11.1\5.11.1\Src\qtbase\lib\Qt5Gui.lib
    C:\Source\Qt\Qt5.11.1\5.11.1\Src\qtbase\lib\Qt5Widgets.lib
    C:\Source\Qt\Qt5.11.1\5.11.1\Src\qtbase\lib\qtmain.lib
    C:\Source\Qt\Qt5.11.1\5.11.1\Src\qtbase\lib\qtpcre2.lib
    C:\Source\Qt\Qt5.11.1\5.11.1\Src\qtbase\lib\qtharfbuzz.lib
    C:\Source\Qt\Qt5.11.1\5.11.1\Src\qtbase\lib\qtlibpng.lib
    C:\Source\Qt\Qt5.11.1\5.11.1\Src\qtbase\lib\qtfreetype.lib
    c:\Source\Qt\Qt5111\Qt5WinExtrasx64.lib (I modified qt5winextras, does not relate though)
    C:\Source\Qt\Qt5.11.1\5.11.1\Src\qtbase\plugins\platforms\qwindows.lib
    C:\Source\Qt\Qt5.11.1\5.11.1\Src\qtbase\lib\Qt5FontDatabaseSupport.lib
    C:\Source\Qt\Qt5.11.1\5.11.1\Src\qtbase\lib\Qt5EventDispatcherSupport.lib
    C:\Source\Qt\Qt5.11.1\5.11.1\Src\qtbase\lib\Qt5ThemeSupport.lib
    C:\Source\Qt\Qt5.11.1\5.11.1\Src\qtbase\lib\Qt5WindowsUIAutomationSupport.lib
    C:\Source\Qt\Qt5.11.1\5.11.1\Src\qtbase\lib\libEGL.lib
    C:\Source\Qt\Qt5.11.1\5.11.1\Src\qtbase\lib\libGLESv2.lib
    C:\Source\Qt\Qt5.11.1\5.11.1\Src\qtbase\lib\preprocessor.lib
    C:\Source\Qt\Qt5.11.1\5.11.1\Src\qtbase\lib\translator.lib
    ws2_32.lib
    Mincore.lib
    Winmm.lib
    Dwmapi.lib
    Imm32.lib
    d3d9.lib
    dxguid.lib

    My static linked application is quite large (12.38MB) compared to the same application written utilizing Win32 (398KB).

    At least it is not as large as the 'Shared' deployment which is 89.4MB.

    Thanks all.


Log in to reply