Introduction
Statically compile qt5.6, statically compile qt5.7, statically compile qt5.8
Install Qt
Go to the Qt official website to download the Qt installation package. To
install Qt and source code, be sure to check the source option and
add bin to the system variable
tool
Need python3 and perl, vs2015 third-party tools, go to the official download and install
Test whether the tool is successfully installed on the command line
configue
First modify the file C:\Qt\Qt5.6.2\5.6\Src\qtbase\mkspecs\common\msvc-desktop.conf to replace MD with MT static compilation
Then the terminal cd command opened above jumps to the Qt source directory and enters the following command
5.6
configure -confirm-license -opensource -platform win32-msvc2015 -debug-and-release -static -prefix "C:\qt\static-vs2015-qt" -qt-sql-sqlite -qt-sql-odbc -plugin-sql-sqlite -plugin-sql-odbc -qt-zlib -qt-libpng -qt-libjpeg -opengl desktop -target xp -qt-freetype -qml-debug -no-angle -nomake tests -nomake examples
5.8
configure -confirm-license -opensource -platform win32-msvc2015 -debug-and-release -static -prefix "C:\qt\static-vs2015-qt" -qt-sqlite -qt-zlib -qt-libpng -qt-libjpeg -opengl desktop -qt-freetype -qml-debug -no-angle -nomake tests -nomake examples
In 5.8, you need to change -qt-sql-sqlite to -qt-sqlite. Since 5.7.0, configure has removed the support for the -target xp option in the source code.
nmake
Sometimes there is a problem with the generated pri file (there is a problem with the string intercepted when getting the cl version), you need to manually modify it
The modification is as follows, if the pri file does not report an error, there is no need to modify it
CONFIG+= debug static rtti no_plugin_manifest directwrite qpa
host_build {
QT_ARCH = i386
QT_TARGET_ARCH = i386
} else {
QT_ARCH = i386
}
QT_CONFIG += minimal-config small-config medium-config large-config full-config debug_and_release build_all release debug static zlib gif jpeg png freetype harfbuzz build_all accessibility opengl dbus audio-backend directwrite native-gestures qpa concurrent
#versioning
QT_VERSION = 5.6.2
QT_MAJOR_VERSION = 5
QT_MINOR_VERSION = 6
QT_PATCH_VERSION = 2
QT_EDITION = OpenSource
QMAKE_TARGET_OS = xp
QT_DEFAULT_QPA_PLUGIN = qwindows
QT_CL_MAJOR_VERSION = 19
QT_CL_MINOR_VERSION = 00
QT_CL_PATCH_VERSION = 24210
compile
compile with nmake
You may encounter this problem when compiling 5.7 and 5.8, just change the qtuiohandler.cpp file to utf-8 encoding with BOM
Install
nmake install
Configure Qt Creator
Add the Qt version, prompting a warning that qmlscene is not installed, copy the previous qmlscene.exe to the bin folder in the static library to
add build kit