Could not find or load the Qt platform plugin “win

2019-07-26 19:54发布

问题:

First of all, to prevent duplicate reports I have tried multiple solutions given here, here, here, here and here.

I am using Qt 5.5.1 with Visual Studio 2012 and developed my app on Windows 10 x64 (not using Qt Creator). Application is compiled in release mode.

Actually, my application is working on my PC, without any issues and the only libraries I need in my directory are:

Qt5Core.dll
Qt5Gui.dll
Qt5WinExtras.dll
Qt5Widgets.dll
Qt5Network.dll
msvcp110.dll
msvcr110.dll

Now, when I try to launch my application on fresh installation of Windows 7 x86 I am getting the following error message:

This application failed to start because it could not find or load the Qt platform plugin "windows".

Reinstalling the application may fix this problem.

Now I can't get rid of it. According to the previously asked questions it can be a issue with qwindows.dll file (or more precisely with application couldn't locate it), first of all I made a deploy of my release directory like this:

[..]\msvc2012\bin>windeployqt.exe <PATH>

It has generated all files that are needed for my application to launch, including platforms/qwindows.dll so I have simply copied all of them to Windows 7 directory without any effect - error still occurs.

I have also tried to manually copy a qwindows.dll from the msvc2012\plugins\platforms - no effect,

Last step I did was a inspection of my application in the Dependency Walker - suprisingly, there is no qwindows.dll related dependency:

image

So I am out of ideas now, what is the problem here?

回答1:

This is what I do to deploy QOwnNotes (Qt5) under Windows: https://github.com/pbek/QOwnNotes/blob/develop/appveyor.yml

# AppVeyor build configuration
# http://www.appveyor.com/docs/build-configuration
os: unstable
skip_tags: true

install:
- set QTDIR=C:\Qt\5.5\mingw492_32
- set PATH=%PATH%;%QTDIR%\bin;C:\MinGW\bin
- set RELEASE_PATH=appveyor\release

before_build:
# getting submodules
- git submodule update --init

build_script:
# using a header file without MemoryBarrier, that causes the build to fail
- copy appveyor\qopenglversionfunctions.h %QTDIR%\include\QtGui
# workaround for MinGW bug
- sed -i s/_hypot/hypot/g c:\mingw\include\math.h
- cd src
# we need to modify that to make it running on AppVeyor
- sed -i "s/CONFIG += c++11/QMAKE_CXXFLAGS += -std=gnu++0x/g" QOwnNotes.pro
- "echo #define RELEASE \"AppVeyor\" > release.h"
# setting the build number in the header file
- "echo #define BUILD %APPVEYOR_BUILD_NUMBER% > build_number.h"
- qmake QOwnNotes.pro -r -spec win32-g++
#  - qmake QOwnNotes.pro -r -spec win32-g++ "CONFIG+=debug"
- mingw32-make
# creating the release path
- md ..\%RELEASE_PATH%
# copy the binary to our release path
- copy release\QOwnNotes.exe ..\%RELEASE_PATH%
# copy OpenSSL DLLs to the release path
- copy ..\appveyor\OpenSSL\libeay32.dll ..\%RELEASE_PATH%
- copy ..\appveyor\OpenSSL\libssl32.dll ..\%RELEASE_PATH%
- copy ..\appveyor\OpenSSL\ssleay32.dll ..\%RELEASE_PATH%
# copy portable mode launcher to the release path
- copy ..\appveyor\QOwnNotesPortable.bat ..\%RELEASE_PATH%
# copy translation files
- copy languages\*.qm ..\%RELEASE_PATH%
- cd ..\%RELEASE_PATH%
# fetching dependencies of QT app
# http://doc.qt.io/qt-5/windows-deployment.html
- windeployqt --release QOwnNotes.exe
# this dll was missed by windeployqt
- copy ..\libwinpthread-1.dll . /y
# this dll didn't work when released by windeployqt
- copy "..\libstdc++-6.dll" . /y
# for some reason AppVeyor or windeployqt uses a copy of the German
# translation file as English one, which screws up the English user interface
- del "translations\qt_en.qm"

artifacts:
# pushing entire folder as a zip archive
- path: appveyor\release
    name: QOwnNotes

deploy:
# Deploy to GitHub Releases
- provider: GitHub
    artifact: QOwnNotes
    draft: false
    prerelease: false
    auth_token:
    secure: spcyN/Dz3B2GXBPii8IywDLq6vfxC1SrN+xR2wMerFM7g2nTy0Lrh5agQONFoInR
    on:
    branch: master

notifications:
# Gitter webhook
- provider: Webhook
    url: https://webhooks.gitter.im/e/b6ef22402eb4af50f73a
    on_build_success: true
    on_build_failure: true
    on_build_status_changed: false

I hope that helps a little...