简体   繁体   English

在Windows上部署Qt应用程序?

[英]Deploying a Qt application on Windows?

I'm new to Qt and cannot figure out how to deploy a simple Qt application on Windows. 我是Qt的新手,无法弄清楚如何在Windows上部署简单的Qt应用程序。 It runs fine when run from inside Qt Creator, but it won't run when directly executed. 它从Qt Creator内部运行时运行正常,但直接执行时不会运行。 I have the newest version of the Qt SDK installed and am using all of the default settings. 我安装了最新版本的Qt SDK并使用了所有默认设置。

I have read dozens of "how to" guides, all of which provided conflicting information, in addition to dozens upon dozens of forum threads, blog posts, and questions on here. 我已经阅读了几十个“如何”指南,除了几十个论坛帖子,博客帖子和问题之外,所有这些都提供了相互矛盾的信息。 I simply cannot find instructions that clearly explain how to deploy a Qt application on Windows. 我根本找不到清楚解释如何在Windows上部署Qt应用程序的说明。

I tried putting all the DLLs I could find in the application directory, but that didn't work. 我尝试将我能找到的所有DLL放在应用程序目录中,但这不起作用。 I also tried building Qt statically, but that didn't work either. 我也尝试过静态构建Qt,但这也不起作用。

Can anyone help me out? 谁能帮我吗?

EDIT: Thank you both for your replies. 编辑:谢谢你们的回复。 Here is some additional information: 以下是一些其他信息:

I am using "Qt Creator 2.4.1, Based on Qt 4.7.4" 我正在使用“Qt Creator 2.4.1,基于Qt 4.7.4”

I have the following includes across different files: 我有以下几种不同的文件:

#include <QtGui/QApplication>
#include <QDebug>
#include <QTextEdit>
#include <QtGui>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include "qthread.h"
#include "windows.h"
#include <QMessageBox>

I'm using the default compiler that came with Qt, MinGW. 我正在使用Qt,MinGW附带的默认编译器。

The simple solution is to include the Qt dlls with your deployment, placing them in the same location as the executable. 简单的解决方案是将Qt dll包含在您的部署中,并将它们放在与可执行文件相同的位置。 Be aware that Qt uses different dlls for release vs. debug builds, so don't accidentally deploy a debug build. 请注意,Qt使用不同的dll进行发布和调试构建,因此不要意外地部署调试版本。

Using static libraries is also viable. 使用静态库也是可行的。 Your edit states you've tried both static and same-directory deployment. 您的编辑声明您已尝试静态和同一目录部署。 If neither of these (especially the static build) are working, you're doing something seriously wrong and it's rather difficult to debug over a board like SO. 如果这些都没有(特别是静态版本)正在工作,那么你就会做一些严重错误的事情,并且很难通过SO这样的电路板进行调试。

First of all, please post the details like 首先,请发布详细信息

Which qt version you are working on? 您正在使用哪个qt版本? What modules are you using - QtNetwork, QTGui etc ? 您使用的是哪些模块 - QtNetwork,QTGui等?

Lastly what compiler are you using, MinGW, MSVC ? 最后你使用的是什么编译器,MinGW,MSVC?

All you need to do is deploy QTCore dll and other dlls for modules you have included in your project in the application directory. 您需要做的就是为项目中包含的模块部署QTCore dll和其他dll应用程序目录。

Further, if you are using MSVC compiler, you will have to deploy MSVC runtime. 此外,如果您使用的是MSVC编译器,则必须部署MSVC运行时。 You can find the redistributable on the microsoft website. 您可以在microsoft网站上找到可再发行的。

Alternatively if you are using mingw then you might need to deploy proper g++ runtime. 或者,如果您使用mingw,则可能需要部署正确的g ++运行时。

If you are still unable to deploy the application with above information, provide the additional details so I can suggest the correct way. 如果您仍然无法使用上述信息部署应用程序,请提供其他详细信息,以便我建议正确的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM