【问题标题】:Could not find or load the Qt platform plugin "windows"无法找到或加载 Qt 平台插件“windows”
【发布时间】:2017-03-01 16:20:16
【问题描述】:

首先,为了防止重复报告,我尝试了多种解决方案,给出了hereherehereherehere

我将 Qt 5.5.1 与 Visual Studio 2012 结合使用,并在 Windows 10 x64 上开发了我的应用程序(不使用 Qt Creator)。应用程序在发布模式下编译。

实际上,我的应用程序在我的 PC 上工作,没有任何问题,我的目录中唯一需要的库是:

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

现在,当我尝试在全新安装的 Windows 7 x86 上启动我的应用程序时,我收到以下错误消息:

此应用程序无法启动,因为它无法找到或加载 Qt 平台插件“windows”。

重新安装应用程序可能会解决此问题。

现在我无法摆脱它。根据之前提出的问题,这可能是qwindows.dll 文件的问题(或者更准确地说是应用程序找不到它),首先我部署了我的发布目录,如下所示:

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

它已经生成了我的应用程序启动所需的所有文件,包括platforms/qwindows.dll,所以我只是简单地将它们全部复制到 Windows 7 目录中而没有任何效果 - 仍然会出现错误。

我还尝试从msvc2012\plugins\platforms 手动复制qwindows.dll - 无效,

我做的最后一步是检查我在 Dependency Walker 中的应用程序 - 令人惊讶的是,没有与 qwindows.dll 相关的依赖项:

image

所以我现在没有想法,这里有什么问题?

【问题讨论】:

  • 它不会显示为依赖项,但它仍然是。您是否将它放在相对于可执行文件的platforms 文件夹中?
  • @ddriver 是的,一直在尝试多种方法,包括在qt.conf 中定义路径。
  • “我只是将它们全部复制到了 Windows 7”:您在 Windows 7 中的哪个位置复制了这些文件?
  • @wasthishelpful 好吧,没关系,因为我的应用程序.exe 在那里,所以它可能在桌面文件夹或文档上。重要的是结构是相同的。 http://i.imgur.com/k91bYHg.png
  • ...您能否编辑您的问题并添加所有已部署的文件? (我的意思是确切的目录结构)

标签: c++ windows visual-studio qt dll


【解决方案1】:

这是我在 Windows 下部署 QOwnNotes (Qt5) 所做的: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

希望对你有所帮助...

【讨论】:

  • 你能告诉我如何在windows中执行上面的yml吗?我无法让 QOwnNotes 最新的 win 发行版在 Win 10 上运行。
  • appveyor.yml 并不是要在 Windows 上“运行”。它由 AppVeyor 在ci.appveyor.com/project/pbek/qownnotes/history 上解释以构建 QOwnNotes,但您可以看到我在做什么。
  • > 我无法让 QOwnNotes 最新的 win 发行版在 Win 10 上运行,@NikhilVJ 你想要达到什么目的?也许在github.com/pbek/QOwnNotes/issues 上发布问题。
  • 对不起,我已经发布了这个问题。可以与以前的版本一起使用。
最近更新 更多