Qt中的独立exe [英] standalone exe in Qt
问题描述
我想在Qt msvc 2010 5中制作一个独立的.exe文件.我将模式更改为"release"并构建我的项目,然后将release/debug文件夹中的.exe文件复制到Qt目录中的bin目录中,然后我复制所有bin文件夹.它可以在我的计算机上正常工作,但是当我将bin文件夹移动到其他计算机时,.exe文件不起作用.我在另一台计算机上安装了Visual c ++ 2010可再发行组件包,但仍然无法正常工作.我该怎么办?
I want to make a standalone .exe file in Qt msvc 2010 5. I change the mode to "release" and build my project and I copy the .exe file in release/debug folder to bin directory in Qt directory and then I copy all the bin folder. it works properly in my computer, but when I move the bin folder to other computers the .exe file doesn't work. I installed visual c++ 2010 redistributable package in the other computer but still it doesn't work. what should I do?
推荐答案
答案很可能是另一台计算机未安装Qt.如果要在Windows上使用完全独立的Qt应用程序(静态链接),请查看以下内容: http://qt- project.org/wiki/Build_Standalone_Qt_Application_for_Windows
The answer is most likely that the other machine doesn't have Qt installed. If you want a wholly standalone Qt app on Windows (statically linked), check this out: http://qt-project.org/wiki/Build_Standalone_Qt_Application_for_Windows
一些快速构建说明-
- 确保已安装python并在路径中获取Qt 源代码 ( http://download.qt-project.org/official_releases/qt/5.1/5.1.1/single/qt-everywhere-opensource-src-5.1.1.zip )
- 解压缩该zip文件并在其中打开Visual Studio命令提示符 目录
- 执行
configure -static -release -no-audio-backend -opengl desktop -opensource -confirm-license
- 执行
nmake
(这将编译所有Qt,并需要一些时间,具体取决于您的处理能力) - 从qt的构建中将CONFIG + = static添加到您的.pro文件调用
qmake
刚完成,然后在您的项目上运行nmake
.然后,您将获得一个 静态链接的二进制文件.您会知道,因为即使很小 程序的大小将> 5MB.
- Make sure you have python installed and in your path Get the Qt source code (http://download.qt-project.org/official_releases/qt/5.1/5.1.1/single/qt-everywhere-opensource-src-5.1.1.zip)
- unzip the zip file and open a Visual Studio command prompt in that directory
- execute
configure -static -release -no-audio-backend -opengl desktop -opensource -confirm-license
- execute
nmake
(this will compile all of Qt and will take a while depending on your processing power) - add CONFIG+=static to your .pro file call
qmake
from the build of qt you just made and then runnmake
on your project. You'll then get a statically linked binary. You'll know because even a very small program will be > 5MB in size.
这篇关于Qt中的独立exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!