Statically linked app with Qt gives error: Failed to load platform plugin “windows”

前端 未结 5 1700
生来不讨喜
生来不讨喜 2020-12-31 13:27

I have built Qt 5.0.1 statically in VS 2010 under Windows 7 x64. The configuration parameters were

configure -debug-and-release -opensource -confirm-license          


        
5条回答
  •  [愿得一人]
    2020-12-31 13:51

    I just had the same problem, so here is my solution:

    First of course build QT with the -static parameter.

    Add the following libs to your build:

    Qt5PlatformSupport.lib
    qwindows.lib
    imm32.lib
    

    Add the following path to your library paths:

    $(QTDIR)\plugins\platforms
    

    In your code (preferably main.cpp) add the following line:

    Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
    

    The resulting build should not depend on any qt-related dlls.

提交回复
热议问题