Qt: Qt 5.* &vs2015 compile static library version

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
write picture description here
install Qt and source code, be sure to check the source option and
write picture description here
add bin to the system variable
write picture description here

tool

Need python3 and perl, vs2015 third-party tools, go to the official download and install
write picture description here

Test whether the tool is successfully installed on the command line
write picture description here

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
write picture description here

write picture description here

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

write picture description here
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
write picture description here
write picture description here

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

write picture description here
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
write picture description here
add build kit
write picture description here

quote

http://doc.qt.io/qt-5/configure-options.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325812537&siteId=291194637