問題描述
我用 QML(Qt 5 的一部分)編寫了幾個應用程序.在我之前提出的一個問題中 (https://softwareengineering.stackexchange.com/questions/213698/deploying-qt-based-app-on-mac-os-x),我找到了在 OS X 上部署我的應用程序的解決方案(使用 macdeployqt 工具).
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).
在 Windows 上部署 Qt4 應用程序很容易:
Deploying Qt4 apps on Windows was easy:
- 您在發布模式下編譯它.
- 您復制了必要的庫 (DLL).
- 您進行了測試,效果很好.
不幸的是,這種方法在 Qt5 中不起作用(我什至在 qwindows.dll 文件中包含了平臺文件夾,但它不起作用).經過幾天的嘗試,我放棄并編譯了一個靜態版本的Qt5.
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.
同樣,它不起作用.該應用程序可在安裝了 Qt 的 PC 上運行,但在干凈"的 PC 上會崩潰.作為旁注,Windows 8/8.1 系統不會發出警告或消息通知我有關應用程序崩潰的信息.但是在 Windows 7 中,一條消息通知我應用程序崩潰了.
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.
我試過運行 Dependency Walker (depends.exe),我的應用程序靜態構建中的所有庫看起來都很好.
I've tried running Dependency Walker (depends.exe) and all libraries in the static build of my application seemed fine.
在 Windows 8 中,我沒有收到任何錯誤.但是在depends.exe 中分析應用程序后,我收到了來自QtGui.dll 的訪問沖突.確切的錯誤是
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
在地址 0x61C2C000 的QT5GUI.DLL"中發生第二次機會異常 0xC0000005(訪問沖突).
Second chance exception 0xC0000005 (Access Violation) occurred in "QT5GUI.DLL" at address 0x61C2C000.
有什么我遺漏的嗎(比如一個額外的 DLL 或配置文件)?
Is there something that I am missing (say an extra DLL or config file)?
申請信息:
- 使用 Qt 5.2.1 編寫和編譯
- 使用 Quick/QML.
- 使用網絡模塊.
- 使用 webkit 模塊.
- 使用藍牙模塊.
- QML 文件是用 Quick 2.2 編寫的
推薦答案
在 Qt 論壇中挖掘了幾個小時后,我發現我需要復制qml"文件夾(通常位于 C:/Qt/5.2.1/qml) 到應用程序的根目錄.這樣做之后,我的應用程序的動態和靜態版本都可以在普通系統上運行.
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.
程序目錄(MinGW 4.8 32 位,動態):
正如 hyde 所說,使用 windeployqt
工具(
) 將必要的文件復制到應用程序的文件夾中.之后,將所需的 QML 組件從
復制到您的應用程序文件夾.生成的文件夾應類似于:
As hyde said, use the windeployqt
tool (<qt path><version>inwindeployqt.exe
) to copy the necessary 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:
- 平臺(文件夾)
- QtQuick(文件夾)
- 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
程序目錄(靜態)
靜態編譯應用程序,然后將所需的 QML 組件從
復制到應用程序的文件夾中.生成的文件夾應類似于:
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:
- QtQuick(文件夾)
- QtQuick.2(文件夾)
- 您需要的任何其他 QML 組件
- app.exe
我認為崩潰的原因是 Qt5Gui.dll
(動態和靜態)在運行時嘗試"加載 QtQuick* 文件夾,但找不到它們(因此崩潰了加載期間的應用程序).
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 應用程序的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!