为 Visual Studio 2017 32 位构建 Qt(静态链接) [英] Build Qt (static linking) for Visual Studio 2017 32bits

查看:43
本文介绍了为 Visual Studio 2017 32 位构建 Qt(静态链接)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 Windows 7 SP1 机器上,我想在 Visual Studio 中使用 Qt 并使用静态链接的 Visual Studip 编译 Qt 项目,以便能够在单个 .exe 文件中共享我的项目.由于没有用于 Visual Studio 2017 32 位的预编译库(尽管它们存在用于 x64),我将从源代码编译 Qt.

On my Windows 7 SP1 machine I would like to use Qt in Visual Studio and compile Qt projects with Visual Studip with static linking,to be able to share my projects in a single .exe file. Since there are no precompiled libraries for Visual Studio 2017 32bits (although they exists for x64),i'm going to compile Qt from sources.

按照 Qt 的文档,我开始安装 Python 2.7.13 和 Active-Perl,并将它们的安装路径添加到 PATH 变量中,以及 gnuwin32/bin 文件夹

Following Qt's documentation,I started by installing Python 2.7.13 and Active-Perl,and adding their installation path to the PATH variable,along with the gnuwin32/bin folder

然后我在 C:\Qt 下创建了一个 qt5vars.cmd 文件,这是他的内容:

Then i created a qt5vars.cmd file under C:\Qt,here's his content :

REM Set up \Microsoft Visual Studio 2017, where <arch> is \c amd64, \c x86, etc.
CALL "C:\Program Files\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86
SET _ROOT=C:\Qt\5.9.1
SET PATH=%_ROOT%\qtbase\bin;%_ROOT%\gnuwin32\bin;%PATH%
REM Uncomment the below line when using a git checkout of the source repository
#REM SET PATH=%_ROOT%\qtrepotools\bin;%PATH%
SET _ROOT=

最后我解压了 Qt 源代码(下载自 这里 到 C:\Qt\5.9.1,然后在 C:\Qt\jom 下 jom

And finally I unzipped Qt sources (downloaded from here to C:\Qt\5.9.1,and jom under C:\Qt\jom

我打算使用这些命令(在执行 qt5vars.cmd 之后)来编译和安装 Qt:

I'm planning to use these commands (after executing qt5vars.cmd) to compile and install Qt :

configure -debug-and-release -opensource -platform win32-msvc2017 -static -nomake examples -nomake tests -prefix C:\Qt-5.9.1
jom -j 2
jom install

我已经在 VS2017 中安装了 Qt vs 工具.

I already installed Qt vs tools in VS2017.

程序是否正确,或者我应该改变什么?(特别是在configure命令中)

Is the procedure correct,or should I change something ? (particularly in the configure command)

推荐答案

看起来不错.我唯一的评论是:删除 gnuwin32 路径,因为我看不出您需要它的原因.

Looks good. My only remarks would be: To remove gnuwin32 path as I don't see a reason why would you need it.

并考虑进行影子构建以保持 Qt 源不受污染.

And consider making a shadow build to keep Qt sources unpolluted.

set _SHADOW_DIR="C:\build_static"
set _SOURCE_DIR="C:\SrcQt5.9.1"
...
cd %_SHADOW_DIR%
call %_SOURCE_DIR%\configure ...

这篇关于为 Visual Studio 2017 32 位构建 Qt(静态链接)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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