作者:广东蒗缦m莎 | 来源:互联网 | 2024-10-23 22:01
Qt程序写完后,想要生成一个exe文件,那么可以参考以下方法工具:Qt5.9.9我们以程序2048为例将左下角debug改为release,然后点击左侧“项目”,找到build的步
Qt程序写完后,想要生成一个exe文件,那么可以参考以下方法
工具:Qt5.9.9
我们以程序2048为例
将左下角debug改为release,然后点击左侧“项目”,找到build的步骤下文件目录里的exe文件

找到了

但是此时点击exe文件是打不开的
原因是缺少qt必要的库文件,想要在自己电脑本机上面运行的最简单的方式是将qt安装的bin目录拷贝到环境变量中
但是这样只是保证了在自己的pc上面运行,没有装qt的pc依然无法运行
如果想在其他的pc上面运行,还需要了解qt的发布方式(将bin文件中的.dll文件封装到.exe中。
我们先把这个exe文件拷贝出来到某个文件夹里(我复制到桌面上了)

接着,我们在win10下搜索QT:
点击这个


接着输入命令行,cd /d 路径(指的是需要打包的exe程序目录,就是刚才拷贝出来的exe程序所在的目录),回车后:

输入如下命令行:windeployqt 程序名 敲击回车。这一步操作是将所需的库文件全都拷贝到exe程序的当前文件:

这时再打开程序目录:

这时就可以直接打开exe文件了
