在Windows上部署Qt 5应用程序 [英] Deploying Qt 5 App on Windows
问题描述
在Windows上部署Qt4应用程序很简单:
- 您复制了必需的库(DLL)。
- 您已经测试过,它的工作。
不幸的是,这种方法在Qt5中不起作用(我甚至包括了qwindows.dll文件的platform文件夹,它没有起作用)。经过几天的尝试,我放弃了编辑了一个静态版本的Qt5。
再次,它没有工作。该应用程序在安装了Qt的PC上工作,但它在干净的PC上崩溃。作为附注,Windows 8 / 8.1系统不会发出警告或通知我有关应用程序崩溃的消息。但是在Windows 7中,一条消息通知我应用程序崩溃。
我已经尝试运行Dependency Walker(depends.exe)和静态构建我的应用程序中的所有库似乎很好。
在Windows 8中,我没有收到任何错误。但是在将该应用程序分析到depends.exe之后,我会收到源自QtGui.dll的访问冲突。确切的错误是
第二次机会异常0xC0000005(访问冲突)发生在地址为0x61C2C000的QT5GUI.DLL中。
有没有什么我想要的(说一个额外的DLL或配置文件)?
应用程序信息:
- 使用Qt 5.2.1
- 使用Quick / QML编写。 / li>
- 使用网络模块。
- 使用webkit模块。
- 使用蓝牙模块。 >
- QML文件以Quick 2.2编写
之后有几个小时在Qt论坛中挖掘,我发现我需要将qml文件夹(通常位于C:/Qt/5.2.1/qml)中复制到应用程序的根目录下。在这样做之后,我的应用程序的动态和静态版本都适用于香草系统。
程序目录MinGW 4.8 32位,动态):
如 hyde 说,使用 windeployqt
工具(< qt path> \< version> \bin\windeployqt.exe
)将nescesary文件复制到应用程序的文件夹。之后,将所需的QML组件从< qt path> \< version> \qml\
复制到应用程序的文件夹。生成的文件夹应该类似于:
- 平台(文件夹)
- QtQuick(folder) / li>
- QtQuick.2(文件夹)
- 您需要的任何其他QML组件
- 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
< hr>
程序目录(静态)
静态编译应用程序,然后复制所需的QML组件从< qt path> \< version> \qml\
到应用程序的文件夹。生成的文件夹应该类似于:
- QtQuick(folder)
- QtQuick.2 )
- 您需要的任何其他QML组件
- app.exe
- 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
<我认为崩溃的原因是Qt5Gui.dll(动态和静态)尝试加载QtQuick *文件夹在运行时间,但找不到它们(从而在加载期间崩溃应用程序)。
I've written a couple of applications in QML (part of Qt 5). In a question that I've made before (https://softwareengineering.stackexchange.com/questions/213698/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屋!