如何为Qt应用程序创建可执行文件? [英] How to create executable file for a Qt Application?

查看:126
本文介绍了如何为Qt应用程序创建可执行文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在互联网上搜索一些有用的和清楚的信息,这是一个琐碎的事情是很难做。恼人的事情。

I've been searching on the internet for some useful and clear information about this, it's annoying that such a trivial thing is so hard to do.

需要为我的Qt项目创建一个可执行文件,以便在其他计算机上运行它。我的项目在Qt Creator中运行得很好,但是当我尝试运行在发行文件夹中创建的可执行文件时,我得到一些DLL的错误,尽管我把它们都放在我的.exe的同一个目录下,错误关于进程内的dll(QtCore4.dll)的入口点。

What I need is to create an executable file for my Qt project, in order to run it in other computers. My project runs nicely in the Qt Creator, but when I try to run the executable created in the release folder I get errors about some dll missing, and though I have put all of them in the same directory of my .exe I now got some errors about entrypoints in procedures inside the dll (QtCore4.dll).

解决方案看起来像一个静态链接,我找到了很多信息,但没有的他们真的帮助了我。这是我到目前为止所尝试的:

The solution looks like to be a static linking, I've found many information about it, but none of them really helped me. Here is what I have tried so far:


  • 使用在发布文件夹中创建的可执行文件如上所述。

  • 静态链接,按照本教程(和许多其他,几乎相同的东西): http://doc.qt.io/qt-4.8/deployment-windows.html 但我在configure -static时得到以下错误:NMAKE:fatal error U1077:'c :\Arquivos de programas \Microsoft Visual Studio 9.
    0 \VC\BIN\cl.EXE':返回代码'0x2'
    停止。
    建立qmake失败,返回代码2

  • Using the executable created in the release folder as I said above.
  • Static Linking, following this tutorial (and many others, all almost the same thing): http://doc.qt.io/qt-4.8/deployment-windows.html but I get the following error during the "configure -static": NMAKE : fatal error U1077: '"c:\Arquivos de programas\Microsoft Visual Studio 9. 0\VC\BIN\cl.EXE"' : return code '0x2' Stop. Building qmake failed, return code 2

因为我找不到任何解决方案,所以这里我只是试图为我的Qt项目创建一个可执行文件,希望你们可以给我一些光这里。

For that I couldn't find any solution, so here I am, just trying to create an executable file for my Qt project, hope you guys can give me some light here.

推荐答案

寻找mingw子文件夹深入qt树,qt实用程序驻留,并复制需要的dll的。

Basically you have to look for mingw subfolder deep into qt tree, where qt utilities reside, and copy needed dll's.

这些步骤基于QT 4.7.4,用于使用正确的共享库打包应用程序。

These are the steps I follow, based upon QT 4.7.4, for packaging the application with correct shared libraries.


  1. 假设您已在c:\qtsdk下安装QT

  2. 打开您的项目,

  3. 转到此目录:C:\QtSDK\Desktop\Qt\4.7.4\mingw\bin - 它包含所有共享库。调试库以d - frex结尾,QtCore.dll是发布版本,而QtCoreD.dll是调试版

  4. 复制至少


  • mingwm10.dll

  • libgcc_s_dw2 -1.dll

  • QtCore4.dll

  • QtGui4.dll

  • mingwm10.dll
  • libgcc_s_dw2-1.dll
  • QtCore4.dll
  • QtGui4.dll

我刚刚构建,测试和部署一个虚拟项目这种方式。

I just built, tested and deployed a dummy project this way.

这篇关于如何为Qt应用程序创建可执行文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆