在Windows上部署Qt 5应用程序 [英] Deploying Qt 5 App on Windows
问题描述
我在QML中编写了几个应用程序(Qt 5的一部分)。在我之前提出的问题(部署基于Qt的应用程序在Mac OS X ),我找到了解决方案部署我的应用程序在OS X(使用macdeployqt工具)。
在Windows上部署Qt4应用程序很容易:
-
-
- 您已复制必要的程式库(DLL) >
不幸的是,这种方法在Qt5中没有工作(我甚至包括与qwindows.dll文件的platforms文件夹,它不工作)。经过几天的尝试,我放弃了并编译了一个静态版本的Qt5。
同样,它没有工作。该应用程序在安装了Qt的PC上运行,但它在干净的PC上崩溃。作为附注,Windows 8 / 8.1系统不会给出警告或消息通知我应用程序崩溃。
我试过运行Dependency Walker(depends.exe)和我的应用程序的静态构建中的所有库似乎很好。
在Windows 8中,我没有得到任何错误。但在对depends.exe进行应用程序分析后,我得到了来自QtGui.dll的访问冲突。确切的错误是
在地址0x61C2C000的QT5GUI.DLL中发生二次机会异常0xC0000005(访问冲突)。
有没有我缺少的东西(说一个额外的DLL或配置文件)?
应用程序信息:
- 使用Qt 5.2.1编写和编译
- 使用Quick / QML。 / li>
- 使用网络模块。
- 使用webkit模块。
- 使用蓝牙模块。 >
- QML文件是在Quick 2.2中编写的
解决方案一些小时挖掘在Qt论坛,我发现,我需要复制qml文件夹(通常位于C:/Qt/5.2.1/qml)到应用程序的根目录。之后,我的应用程序的动态和静态版本都在vanilla系统上工作。
MinGW 4.8 32-bit,dynamic):
由于海德说,使用
windeployqt
工具(< qt path> \< version> \bin\windeployqt.exe
)将nescesary文件复制到应用程序的文件夹。之后,将所需的QML组件从< qt path> \< version> \qml\
复制到应用程序的文件夹。生成的文件夹应类似于:
- platforms(文件夹)
- QtQuick / li>
- QtQuick.2(文件夹)
- 您需要的任何其他QML组件 li> app.exe
- icudt51.dll
- icuin51.dll
- icuuc51.dll
- libgcc_s_dw2-1.dll
- libstdc ++ - 6.dll
- libwindthread-1.dll
- Qt5Core.dll
- Qt5Gui.dll
- Qt5Qml.dll
- dll
- Qt5Network.dll
- Qt5Widgets.dll
< hr>
程序目录(静态)
静态编译应用程序,然后复制所需的QML组件从
< qt path> \< version> \qml\
到您的应用程序的文件夹。生成的文件夹应类似于:
- QtQuick(文件夹)
- QtQuick.2 )
- You compiled it in release mode.
- You copied the necessary libraries (DLLs).
- You tested and it worked.
- Written and compiled with Qt 5.2.1
- Uses Quick/QML.
- Uses the network module.
- Uses the webkit module.
- Uses the bluetooth module.
- The QML files are written in Quick 2.2
- platforms (folder)
- QtQuick (folder)
- QtQuick.2 (folder)
- Any other QML components that you need
- app.exe
- icudt51.dll
- icuin51.dll
- icuuc51.dll
- libgcc_s_dw2-1.dll
- libstdc++-6.dll
- libwindthread-1.dll
- Qt5Core.dll
- Qt5Gui.dll
- Qt5Qml.dll
- Qt5Quick.dll
- Qt5Network.dll
- Qt5Widgets.dll
- QtQuick (folder)
- QtQuick.2 (folder)
- Any other QML components that you need
- app.exe
ul>
我认为崩溃的原因是Qt5Gui.dll(动态和静态)试图加载QtQuick *文件夹,但无法找到它们(从而在加载过程中导致应用程序崩溃)。
I've written a couple of applications in QML (part of Qt 5). In a question that I've made before (Deploying Qt-based app on Mac OS X), I found the solution for deploying my app on OS X (using the macdeployqt tool).
Deploying Qt4 apps on Windows was easy:
Unfortunately, this approach did not work in Qt5 (I even included the platforms folder with the qwindows.dll file and it did not work). After some days of trying, I gave up and compiled a static version of Qt5.
Again, it did not work. The app works on a PC with Qt installed, but it crashes on "clean" PCs. As a side note, Windows 8/8.1 systems don't give a warning or a message notifying me about the app's crash. But in Windows 7 a message notifies me that the application crashed.
I've tried running Dependency Walker (depends.exe) and all libraries in the static build of my application seemed fine.
In Windows 8, I don't get any error. But after profiling the app in depends.exe, I get an access violation originating from QtGui.dll. The exact error is
Second chance exception 0xC0000005 (Access Violation) occurred in "QT5GUI.DLL" at address 0x61C2C000.
Is there something that I am missing (say an extra DLL or config file)?
Application information:
After some hours digging in the Qt Forums, I found out that I need to copy the "qml" folder (normally located in C:/Qt/5.2.1/qml) to the application's root directory. After doing so, both the dynamic and static versions of my application worked on vanilla systems.
Program directory (MinGW 4.8 32-bit, dynamic):
As hyde said, use the windeployqt
tool (<qt path>\<version>\bin\windeployqt.exe
) to copy the nescesary files to your application's folder. After that, copy the required QML components from <qt path>\<version>\qml\
to your application's folder. The resulting folder should look similar to:
Program directory (static)
Compile the application statically, then copy the required QML components from <qt path>\<version>\qml\
to your application's folder. The resulting folder should look similar to:
I think the cause for the crash was that the Qt5Gui.dll (dynamic and static) "tried" to load the QtQuick* folders during run time, but could not find them (thus crashing the application during load).
这篇关于在Windows上部署Qt 5应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!