伸手党可以直接下载本人编译好的Qt512、Qt513、Qt514、Qt515、Qt63
下载Qt源码
以下命令都是在Visual Studio提供的Command Prompt中进行
Qt6需要使用Visual Studio 2019或Visual Studio 2022
Qt6编译需要安装Strawberry Perl,并添加到PATH环境变量
Qt6编译需要安装CMake,并添加到PATH环境变量
官方文档:Building from Source、Configure Options
SET _ROOT=D:\qt-everywhere-src-6.3.1
SET PATH=%_ROOT%\qtbase\bin;%PATH%
SET _ROOT=
configure -confirm-license -debug-and-release -nomake examples -nomake tests -opengl desktop -opensource -qt-freetype -qt-libjpeg -qt-libpng -qt-pcre -qt-sqlite -qt-zlib -skip qtwebengine -static -static-runtime -strip -prefix D:\Qt63
cmake --build . --parallel
cmake --install .
SET _ROOT=D:\qt-everywhere-src-6.2.4
SET PATH=%_ROOT%\qtbase\bin;%PATH%
SET _ROOT=
configure -confirm-license -debug-and-release -nomake examples -nomake tests -opengl desktop -opensource -qt-freetype -qt-libjpeg -qt-libpng -qt-pcre -qt-sqlite -qt-zlib -skip qtwebengine -static -static-runtime -strip -prefix D:\Qt62
cmake --build . --parallel
cmake --install .
SET _ROOT=D:\qt-everywhere-src-6.1.3
SET PATH=%_ROOT%\qtbase\bin;%PATH%
SET _ROOT=
configure -confirm-license -debug-and-release -nomake examples -nomake tests -opengl desktop -opensource -qt-freetype -qt-libjpeg -qt-libpng -qt-pcre -qt-sqlite -qt-zlib -skip qtwebengine -static -static-runtime -strip -prefix D:\Qt61
cmake --build . --parallel
cmake --install .
SET _ROOT=D:\qt-everywhere-src-6.0.4
SET PATH=%_ROOT%\qtbase\bin;%PATH%
SET _ROOT=
configure -confirm-license -debug-and-release -nomake examples -nomake tests -opengl desktop -opensource -qt-freetype -qt-libjpeg -qt-libpng -qt-pcre -qt-sqlite -qt-zlib -skip qtwebengine -static -static-runtime -strip -prefix D:\Qt60
cmake --build . --parallel
cmake --install .
Qt5使用Visual Studio 2017
Qt5使用jom替代nmake以使用多进程编译,把jom解压到PATH环境变量能找到的任何位置即可
官方文档:Building from Source、Configure Options
尽量不要使用5.14.1之前的版本,因为存在问题72903、78003、78827、79090
SET _ROOT=D:\qt-everywhere-src-5.15.5
SET PATH=%_ROOT%\qtbase\bin;%_ROOT%\gnuwin32\bin;%PATH%
SET _ROOT=
configure -confirm-license -debug-and-release -nomake examples -nomake tests -opengl desktop -opensource -qt-freetype -qt-libjpeg -qt-libpng -qt-pcre -qt-sqlite -qt-zlib -skip qtwebengine -static -static-runtime -strip -prefix D:\Qt515
jom -j32
jom -j32 install
SET _ROOT=D:\qt-everywhere-src-5.14.2
SET PATH=%_ROOT%\qtbase\bin;%_ROOT%\gnuwin32\bin;%PATH%
SET _ROOT=
configure -confirm-license -debug-and-release -nomake examples -nomake tests -opengl desktop -opensource -qt-freetype -qt-libjpeg -qt-libpng -qt-pcre -qt-sqlite -qt-zlib -skip qtwebengine -static -static-runtime -strip -prefix D:\Qt514
jom -j32
jom -j32 install
SET _ROOT=D:\qt-everywhere-src-5.13.2
SET PATH=%_ROOT%\qtbase\bin;%_ROOT%\gnuwin32\bin;%PATH%
SET _ROOT=
configure -confirm-license -debug-and-release -nomake examples -nomake tests -opengl desktop -opensource -qt-freetype -qt-libjpeg -qt-libpng -qt-pcre -qt-sqlite -qt-zlib -skip qtwebengine -static -static-runtime -strip -prefix D:\Qt513
jom -j32
jom -j32 install
5.13及更老的版本由于存在前面提到的问题,我是用如下方式解决的
在D:\Qt513
目录下全文搜索Windows Kits
得到类似以下绝对路径
"C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.19041.0\\um\\x64/gdi32.lib"
C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.19041.0\\um\\x64/gdi32.lib
打开Sublime Text使用Ctrl+Shift+F打开全局替换窗口
开启Regular expression正则表达式选项
Find中输入根据绝对路径转换后的正则表达式(先替换带双引号的绝对路径)
"C:\\\\Program Files \(x86\)\\\\Windows Kits\\\\10\\\\lib\\\\10.0.19041.0\\\\um\\\\x64[/\\\\](\w+\.lib)"
Where中填写编译输出的路径
D:\Qt513
Replace中输入捕获的子表达式
$1
点击Replace
再来一次不带双引号的正则表达式
C:\\\\Program Files \(x86\)\\\\Windows Kits\\\\10\\\\lib\\\\10.0.19041.0\\\\um\\\\x64[/\\\\](\w+\.lib)
Replace中输入捕获的子表达式
$1
点击Replace
点击Save All后再Close All Files即可