Nominate our 2022 Qt Champions!

no qt platform could be initialized

  • I'm trying to build an application statically and I compiled and set configurations for corresponding qmake.exe
    However, when I execute the file which is built by the manual static kit, the error occurs and message is like below. (Strange thing is, this error doesn't occur when I run it in the Qt creator. Only when I execute the result exe file directly)
    This application failed to start because no qt platform plugin could be initialized.
    I can not find any other post that shows same error message as mine. How can I solve this problem? I don't know if it will be helpful, I'll attach the compile output.

    23:36:46: Running steps for project untitled...
    23:36:46: Starting: "D:\qt\5.11.1\msvc2015\bin\qmake.exe" C:\Users\Coder\Desktop\qt\untitled\ -spec win32-msvc "CONFIG+=qtquickcompiler"
    Info: creating stash file C:\Users\Coder\Desktop\qt\build-untitled-Qt_5_11_1_mingw53_32_Static-Release.qmake.stash
    23:36:48: The process "D:\qt\5.11.1\msvc2015\bin\qmake.exe" exited normally.
    23:36:48: Starting: "D:\qt\Tools\QtCreator\bin\jom.exe" qmake_all

    jom 1.1.2 - empower your cores

    23:36:48: The process "D:\qt\Tools\QtCreator\bin\jom.exe" exited normally.
    23:36:48: Starting: "D:\qt\Tools\QtCreator\bin\jom.exe"
    D:\qt\Tools\QtCreator\bin\jom.exe -f Makefile.Release
    D:\qt\5.11.1\msvc2015\bin\uic.exe ..\untitled\mainwindow.ui -o ui_mainwindow.h
    cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -O2 -MD -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -EHsc -DUNICODE -D_UNICODE -DWIN32 -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DNDEBUG -I..\untitled -I. -ID:\qt\5.11.1\msvc2015\include -ID:\qt\5.11.1\msvc2015\include\QtWidgets -ID:\qt\5.11.1\msvc2015\include\QtGui -ID:\qt\5.11.1\msvc2015\include\QtANGLE -ID:\qt\5.11.1\msvc2015\include\QtCore -Irelease -I. -I\include -ID:\qt\5.11.1\msvc2015\mkspecs\win32-msvc -Forelease\ @C:\Users\Coder\AppData\Local\Temp\main.obj.73168.15.jom
    cl -BxD:\qt\5.11.1\msvc2015\bin\qmake.exe -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -O2 -MD -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -E D:\qt\5.11.1\msvc2015\mkspecs\features\data\dummy.cpp 2>NUL >release\moc_predefs.h
    cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -O2 -MD -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -EHsc -DUNICODE -D_UNICODE -DWIN32 -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DNDEBUG -I..\untitled -I. -ID:\qt\5.11.1\msvc2015\include -ID:\qt\5.11.1\msvc2015\include\QtWidgets -ID:\qt\5.11.1\msvc2015\include\QtGui -ID:\qt\5.11.1\msvc2015\include\QtANGLE -ID:\qt\5.11.1\msvc2015\include\QtCore -Irelease -I. -I\include -ID:\qt\5.11.1\msvc2015\mkspecs\win32-msvc -Forelease\ @C:\Users\Coder\AppData\Local\Temp\mainwindow.obj.73168.62.jom
    D:\qt\5.11.1\msvc2015\bin\moc.exe -DUNICODE -D_UNICODE -DWIN32 -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DNDEBUG --compiler-flavor=msvc --include release/moc_predefs.h -ID:/qt/5.11.1/msvc2015/mkspecs/win32-msvc -IC:/Users/Coder/Desktop/qt/untitled -ID:/qt/5.11.1/msvc2015/include -ID:/qt/5.11.1/msvc2015/include/QtWidgets -ID:/qt/5.11.1/msvc2015/include/QtGui -ID:/qt/5.11.1/msvc2015/include/QtANGLE -ID:/qt/5.11.1/msvc2015/include/QtCore -I. -I"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" -I"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" -I"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\shared" -I"C:\Program Files (x86)\Windows Kits\8.1\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\winrt" ..\untitled\mainwindow.h -o release\moc_mainwindow.cpp
    cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -O2 -MD -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -EHsc -DUNICODE -D_UNICODE -DWIN32 -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DNDEBUG -I..\untitled -I. -ID:\qt\5.11.1\msvc2015\include -ID:\qt\5.11.1\msvc2015\include\QtWidgets -ID:\qt\5.11.1\msvc2015\include\QtGui -ID:\qt\5.11.1\msvc2015\include\QtANGLE -ID:\qt\5.11.1\msvc2015\include\QtCore -Irelease -I. -I\include -ID:\qt\5.11.1\msvc2015\mkspecs\win32-msvc -Forelease\ @C:\Users\Coder\AppData\Local\Temp\moc_mainwindow.obj.73168.1281.jom
    link /NOLOGO /DYNAMICBASE /NXCOMPAT /INCREMENTAL:NO /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='' publicKeyToken='6595b64144ccf1df' language='' processorArchitecture=''" /MANIFEST:embed /OUT:release\untitled.exe @C:\Users\Coder\AppData\Local\Temp\untitled.exe.73168.2562.jom
    23:36:51: The process "D:\qt\Tools\QtCreator\bin\jom.exe" exited normally.
    23:36:51: Elapsed time: 00:05.

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Your application might be statically built, but that's not the case for its dependencies.

    See the windeployqt tool documentation on how to release an application.

  • @SGaist I don't know what to do. Using windeployqt make dynamically built executable work, but it does not solve the problem of statically built executable.
    Which part of the post should I follow?

  • Lifetime Qt Champion

    If you want to build a fully static executable, you have to first build all its dependencies statically too.

    Which also means that you have to properly abide to the conditions of the licenses of said dependencies.

  • I followed instructions of one blog, but I don't know if all the dependencies are built statically too. Could you let me know whether the commands below build all the dependencies statically?

    1. add to qmake
      QMAKE_LFLAGS += -static -static-libgcc
      QMAKE_CFLAGS_RELEASE += -Os -momit-leaf-frame-pointer
    1. add an environment path
      set Path=C:\Qt\Tools\mingw530_32\bin;%PATH%

    2. Move to Src folder, and command
      configure -static -release -platform win32-g++ -prefix C:\Qt\Static\5.10.0 -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -opengl desktop -no-openssl -opensource -confirm-license -make libs -nomake tools -nomake examples -nomake tests

    3. next
      mingw32-make -k -j4
      mingw32-make -k install

    4. add to qmake.conf
      CONFIG += static

  • Lifetime Qt Champion

    Did you also fully re-build your application with that new Qt build of yours ?

  • If you mean that building my application using newly made kit, then yes.

  • Lifetime Qt Champion

    @Aaron-Kim Full rebuild means: delete build directory, run qmake, build

  • @jsulm Do you mean the build directory of my application? or Qt itself?

  • Lifetime Qt Champion

    The build folder of your application.

  • @SGaist It seems that I did. Is there any way to show you an error log or something?

  • Lifetime Qt Champion

    You can use something like

  • @SGaist I mean, how can I get the verbose log of the error to determine what my problem is?

  • @Aaron-Kim
    you must create a directory called "platforms". In the next step you copy the qwindows.dll in the platform directory.
    You find the dll usually in C:\Qt\Qtx.y.z\x.y.z\mingw73_64\plugins\platforms

  • @Mugga
    fantastic you saved me! Thanks!!!!!!

Log in to reply