Qt 5.x 应用程序 Windows 部署方法
来源:互联网 发布:溢思得瑞人工智能 编辑:程序博客网 时间:2024/06/05 22:52
使用 Qt 5.2.1 开发了一个程序之后,部署竟然用了我很长时间来调试。现在总算搞明白了。
1、源代码使用 UTF-8 编码格式,对于 VC++ 2010 来说,创建并引入头文件 charset.h:
#pragma once// VC 2010 以后,要求源码设置 UTF-8 BOM#if defined(_MSC_VER) && (_MSC_VER >= 1600)# pragma execution_character_set("utf-8")#endif
只要是源代码中使用了中文,都要引入这个头文件。
使用 UTF-8,必须使用如下 DLL:
icudt51.dllicuin51.dllicuuc51.dll
2、必须的 DLL,比如:
Qt5Core.dllQt5Gui.dllQt5Network.dllQt5Sql.dllQt5Websockets.dllQt5Widgets.dll...
3、VC++ 2010 Redistribution Package x86
4、由于 Qt 使用了 Qt 5.2.1 for Windows 32-bit (VS 2010, OpenGL, 517 MB) 这个版本,因此还需要
libEGL.dllLibGLESv2.dllD3DCompiler_43.dll
起初不知道需要这些文件,部署后总是报 This application failed to start because it could not find or load the Qt platform plugin "windows".
还以为是插件目录的问题,折腾了好久,总是不正确,后来在 QtCreator 目录中发现这些 dll,复制过来。
5、插件配置
⑴在应用程序 app.exe 目录下创建插件子目录,类似如下目录结构:
./bin/app.exe./bin/platforms
将 Qt 系统目录中的相应子目录复制过来,文件包括:
qminimal.dllqoffscreen.dllqwindows.dll...
⑵使用 Qt 设置库目录的 API:
QStringList libraryPaths = QStringList() << qApp->applicationDirPath() << qApp->applicationDirPath().append("/plugins");QApplication::setLibraryPaths(libraryPaths);
或者:
QApplication::addLibraryPath(“./plugins”);
⑶使用资源文件 app.qrc,将 qt.conf 配置文件作为资源,加入路径 :/qt/etc/qt.conf,
Qt5Core.dll 加载时默认访问这个配置文件。
⑷使用外部 qt.conf 配置文件
qt.conf 放置于 app.exe 所在目录,内容如下:
[Paths]Plugins=./plugins
6、总结,
以上设置如果不正确,从而找不到 platforms 目录时,会报 This application failed to start because it could not find or load the Qt platform plugin "windows".这个错误。
相关文档,请参考:
http://qt-project.org/doc/qt-5/windows-deployment.html
http://qt-project.org/doc/qt-5/windows-issues.html
http://qt-project.org/doc/qt-5/deployment-plugins.html
1 0
- Qt 5.x 应用程序 Windows 部署方法
- Qt 5.x 应用程序 Windows 部署方法
- 在 Windows 上部署 Qt 应用程序
- Qt 应用程序的部署
- Qt 应用程序的部署
- Qt 应用程序的部署
- MACOS X QT部署
- 演练:部署 Windows 应用程序
- C#Windows应用程序部署
- 部署 Windows 应用程序
- 部署 Windows 应用程序
- Windows应用程序打包部署
- 部署 Windows 应用程序
- QT Windows 部署问题
- 一键发布Qt应用程序(最快方法)- windows
- Qt 5.x 全局热键 for windows
- Tomcat5.5.x中部署Java Web应用程序
- Qt 打包应用程序方法
- Android内核--Activity调度机制
- 查找字符串中第一个不重复的字符的方法。
- Binary Tree Postorder Traversal
- [JSP]Cookie操作陷阱
- 在构造函数中使用new时应注意的事项、析构函数调用
- Qt 5.x 应用程序 Windows 部署方法
- 【树状数组】HUD1556 区间修改单点求值
- Clojure的头保持问题
- PHP中序列化和反序列化
- /usr/local/lib/libz.a: could not read symbols: Bad value
- 在win7下安装Ubuntu 14.04
- Struts2中文国际化乱码问题
- Algorithm学习笔记 --- 珍惜现在,感恩生活
- Pig FOREACH 嵌套循环