Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

qt.qpa.plugin: Could not find the Qt platform plugin "windows" in "%QTLIB%\plugins\platforms"



  • I'm trying to use Qt with Clion IDE using Cmake, the build is successful, yet the execution gives me the following error :

    Warning: QT_DEVICE_PIXEL_RATIO is deprecated. Instead use:
       QT_AUTO_SCREEN_SCALE_FACTOR to enable platform plugin controlled per-screen factors.
       QT_SCREEN_SCALE_FACTORS to set per-screen factors.
       QT_SCALE_FACTOR to set the application global scale factor.
    qt.qpa.plugin: Could not find the Qt platform plugin "windows" in "C:\Qt\Qt5.14.0\5.14.0\mingw73_64\plugins\platforms"
    
    This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fi
    x this problem.
    

    my CmakeLists.txt file :

    cmake_minimum_required(VERSION 3.15)
    project(qt_test)
    
    set(CMAKE_CXX_STANDARD 20)
    
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_AUTORCC ON)
    set(CMAKE_AUTOUIC ON)
    
    add_executable(qt_test main.cpp)
    
    # Tell cmake where Qt is located
    set(Qt5_DIR "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/lib/cmake/Qt5")
    
    # Tell cmake to find the modules Qt5Core and Qt5widgets
    find_package(Qt5 COMPONENTS Core Widgets REQUIRED)
    
    # Link the library to the executable
    target_link_libraries(qt_test Qt5::Core Qt5::Widgets)
    
    

    I added QT_QPA_PLATFORM_PLUGIN_PATH to my environment variables with the value C:\Qt\Qt5.14.0\5.14.0\mingw73_64\plugins\platforms , dll files in this folder :
    platform



  • Ok. In your system env path, is C:\Qt\Qt5.14.0\5.14.0\mingw73_64\bin the first entry?

    Also, you could check for the presence of Qt5Core.dll and Qt5Cored.dll in your C:, for example, try:

    cd \
    dir Qt5core.dll/a/s
    dir Qt5Cored.dll/a/s
    

    maybe there's a Qt5Core.dll (or Qt5Cored.dll) that is for a Qt version earlier than 5.14.0 that's hiding somewhere...



  • Try changing to QT_QPA_PLATFORM_PLUGIN_PATH (instead of QT_QPA_PLATEFORM_PLUGIN_PATH)



  • @hskoglund Thanks for the response, that was just a typo in the post.



  • Hi, also note that the QT_QPA_PLATFORM_PLUGIN_PATH is only used in a QGuiApplication, not in a QCoreApplication or a QApplication Qt program

    Edit: Sorry QT_QPA_PLATFORM_PLUGIN_PATH env. variable is valid for Widgets apps also (my mistake).
    The error must be somewhere else, perhaps there's a missing dll, try setting the env. var QT_DEBUG_PLUGINS=1 and then run DbgView to trace



  • @hskoglund Note that the program runs without any problem in Qt Creator, but I get the same errors when running from Clion or manually executing the .exe file from the explorer.
    Tracing the problem gave me the following output :

    In C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/qwindows.dll:
      Plugin uses incompatible Qt library (5.14.0) [release]
    "The plugin 'C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/qwindows.dll' uses incompatible Qt library. (5.14.0) [release]"
             not a plugin
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/haita/Documents/QtProjects/test_cmake/cmake-build-debug" ...
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/platforms" ...
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/haita/Documents/QtProjects/test_cmake/cmake-build-debug/platforms" ...
    qt.qpa.plugin: Could not find the Qt platform plugin "windows" in "C:\Qt\Qt5.14.0\5.14.0\mingw73_64\plugins\platforms"
    This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
    

  • Lifetime Qt Champion

    As you can see you're mixing debug and release plugins. Make sure there is qwindowsd.dll in C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/



  • @Christian-Ehrlicher Qt 5.14.0 has abolished the "d"-suffix for MinGW (it remains for MSVC) (see for example https://forum.qt.io/topic/109779/windeployqt-exe-comes-with-qt-5-14-not-copy-the-dlls-to-the-app-directory



  • @Christian-Ehrlicher I only have one qwindows.dll file in C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/ , if I should have another version and/or multiple versions where can I find them ?



  • In Qt 5.14.0 MinGW uses the same qwindows.dll both for debug and release builds, so you only having one qwindows.dll is correct.

    But that error message "... incompatible Qt library (5.14.0) ..." means that Qt5Core.dll is built with another version of Qt (not 5.14.0).

    Could you check where your Qt5Core.dll is loaded from?



  • @hskoglund I'm not sure how I can check where is it loaded from, I have the following in my system env path C:\Qt\Qt5.14.0\5.14.0\mingw73_64\bin which contains Qt5Core.dll



  • How did you install your Qt 5.14.0, did you use the online installer or the offline installer?



  • @hskoglund I used the offline installer



  • Ok. In your system env path, is C:\Qt\Qt5.14.0\5.14.0\mingw73_64\bin the first entry?

    Also, you could check for the presence of Qt5Core.dll and Qt5Cored.dll in your C:, for example, try:

    cd \
    dir Qt5core.dll/a/s
    dir Qt5Cored.dll/a/s
    

    maybe there's a Qt5Core.dll (or Qt5Cored.dll) that is for a Qt version earlier than 5.14.0 that's hiding somewhere...



  • @hskoglund All QtCore.dll and QtCored.dll files in Qt directory are for the same version 5.14.0, every other QtCore.dll file in C: belongs to other programs I have in my computer.



  • @hskoglund Restarting my computer after moving C:\Qt\Qt5.14.0\5.14.0\mingw73_64\bin to be the first entry (it wasn't before) solved the problem, now I can see the application's window, yet I get the following output (which I'm not sure if it's an error):

    Warning: QT_DEVICE_PIXEL_RATIO is deprecated. Instead use:
       QT_AUTO_SCREEN_SCALE_FACTOR to enable platform plugin controlled per-screen factors.
       QT_SCREEN_SCALE_FACTORS to set per-screen DPI.
       QT_SCALE_FACTOR to set the application global scale factor.
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms" ...
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/libEGL.dll"
    "Failed to extract plugin meta data from 'C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/libEGL.dll'"
             not a plugin
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/qdirect2d.dll"
    Found metadata in lib C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/qdirect2d.dll, metadata=
    {
        "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
        "MetaData": {
            "Keys": [
                "direct2d"
            ]
        },
        "archreq": 0,
        "className": "QWindowsDirect2DIntegrationPlugin",
        "debug": false,
        "version": 331264
    }
    
    
    Got keys from plugin meta data ("direct2d")
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/qminimal.dll"
    Found metadata in lib C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/qminimal.dll, metadata=
    {
        "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
        "MetaData": {
            "Keys": [
                "minimal"
            ]
        },
        "archreq": 0,
        "className": "QMinimalIntegrationPlugin",
        "debug": false,
        "version": 331264
    }
    
    
    Got keys from plugin meta data ("minimal")
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/qoffscreen.dll"
    Found metadata in lib C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/qoffscreen.dll, metadata=
    {
        "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
        "MetaData": {
            "Keys": [
                "offscreen"
            ]
        },
        "archreq": 0,
        "className": "QOffscreenIntegrationPlugin",
        "debug": false,
        "version": 331264
    }
    
    
    Got keys from plugin meta data ("offscreen")
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/qwebgl.dll"
    Found metadata in lib C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/qwebgl.dll, metadata=
    {
        "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
        "MetaData": {
            "Keys": [
                "webgl"
            ]
        },
        "archreq": 0,
        "className": "QWebGLIntegrationPlugin",
        "debug": false,
        "version": 331264
    }
    
    
    Got keys from plugin meta data ("webgl")
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/qwindows.dll"
    Found metadata in lib C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/qwindows.dll, metadata=
    {
        "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
        "MetaData": {
            "Keys": [
                "windows"
            ]
        },
        "archreq": 0,
        "className": "QWindowsIntegrationPlugin",
        "debug": false,
        "version": 331264
    }
    
    
    Got keys from plugin meta data ("windows")
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins" ...
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/haita/Documents/QtProjects/test_cmake/cmake-build-deb
    ug" ...
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/platforms"
    ...
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms" ...
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/libEGL.dll"
    "Failed to extract plugin meta data from 'C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/libEGL.dll'"
             not a plugin
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/qdirect2d.dll"
    Got keys from plugin meta data ("direct2d")
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/qminimal.dll"
    Got keys from plugin meta data ("minimal")
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/qoffscreen.dll"
    Got keys from plugin meta data ("offscreen")
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/qwebgl.dll"
    Got keys from plugin meta data ("webgl")
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/qwindows.dll"
    Got keys from plugin meta data ("windows")
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/haita/Documents/QtProjects/test_cmake/cmake-build-deb
    ug/platforms" ...
    loaded library "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/qwindows.dll"
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms" ...
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/libEGL.dll"
    "Failed to extract plugin meta data from 'C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/libEGL.dll'"
             not a plugin
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/qdirect2d.dll"
    Got keys from plugin meta data ()
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/qminimal.dll"
    Got keys from plugin meta data ()
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/qoffscreen.dll"
    Got keys from plugin meta data ()
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/qwebgl.dll"
    Got keys from plugin meta data ()
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/qwindows.dll"
    Got keys from plugin meta data ()
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins" ...
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/haita/Documents/QtProjects/test_cmake/cmake-build-deb
    ug" ...
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/platformthe
    mes" ...
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platformthemes" ...
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platformthemes/qxdgdesktopportal.d
    ll"
    Found metadata in lib C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platformthemes/qxdgdesktopportal.dll, metadata=
    {
        "IID": "org.qt-project.Qt.QPA.QPlatformThemeFactoryInterface.5.1",
        "MetaData": {
            "Keys": [
                "xdgdesktopportal",
                "flatpak",
                "snap"
            ]
        },
        "archreq": 0,
        "className": "QXdgDesktopPortalThemePlugin",
        "debug": false,
        "version": 331264
    }
    
    
    Got keys from plugin meta data ("xdgdesktopportal", "flatpak", "snap")
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/haita/Documents/QtProjects/test_cmake/cmake-build-deb
    ug/platformthemes" ...
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/styles" ...
    
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/styles" ...
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/styles/qwindowsvistastyle.dll"
    Found metadata in lib C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/styles/qwindowsvistastyle.dll, metadata=
    {
        "IID": "org.qt-project.Qt.QStyleFactoryInterface",
        "MetaData": {
            "Keys": [
                "windowsvista"
            ]
        },
        "archreq": 0,
        "className": "QWindowsVistaStylePlugin",
        "debug": false,
        "version": 331264
    }
    
    
    Got keys from plugin meta data ("windowsvista")
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/haita/Documents/QtProjects/test_cmake/cmake-build-deb
    ug/styles" ...
    loaded library "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/styles/qwindowsvistastyle.dll"
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/accessible"
     ...
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/accessible" ...
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/haita/Documents/QtProjects/test_cmake/cmake-build-deb
    ug/accessible" ...
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/accessibleb
    ridge" ...
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/accessiblebridge" ...
    
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/haita/Documents/QtProjects/test_cmake/cmake-build-deb
    ug/accessiblebridge" ...
    QLibraryPrivate::unload succeeded on "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/styles/qwindowsvistastyle.dll"
    QLibraryPrivate::unload succeeded on "C:/Qt/Qt5.14.0/5.14.0/mingw73_64/plugins/platforms/qwindows.dll"
    


  • Think you're fine now, all that "QFactoryLoader::QFactoryLoader()...." output is because you turned on plugin tracing, removing that env. variable QT_DEBUG_PLUGINS=1 should fix it.



  • @hskoglund Okay. Thank you that was really helpful!


Log in to reply