Qt 5.9.1 VS2017 静态编译

依赖ICU4C OpenSSL

编译ICU4C(59.1)
使用Cygwin
需要安装bash、GNU make(3.81)、ar(binutils)、ranlib
需要下载ICU source for Unix platforms
1.系统变量Path后面加上C:\cygwin64\bin
2.启动 x86 Native Tools Command Prompt for VS 2017
3.切换目录到”icu/source”
4.bash
5.运行CFLAGS=-MT CXXFLAGS=-MT ./runConfigureICU Cygwin/MSVC –enable-static –disable-shared –prefix=E:/Build/QT/ICU
6.make编译
7.make test测试(可选)
8.make install
9.运行CFLAGS=-MTd CXXFLAGS=-MTd ./runConfigureICU Cygwin/MSVC –enable-static –disable-shared -–enable-debug –disable-release –prefix=E:/Build/QT/ICU
10.make编译
11.make test测试(可选)
12.make install

PS路径不能有空格

编译OpenSSL(1.02.j)
安装Perl
1.启动 x86 Native Tools Command Prompt for VS 2017
2.切换目录到”openssl”
3.perl Configure VC-WIN32 no-asm –prefix=E:/Build/QT/OpenSSL
4.ms\do_ms
5.nmake -f ms\nt.mak编译
6.nmake -f ms\nt.mak test测试(可选)
7.nmake -f ms\nt.mak install

编译QT

1.打开的qtbase\mkspecs\common\msvc-desktop.conf
QMAKE_CFLAGS_RELEASE = $$QMAKE_CFLAGS_OPTIMIZE -MD
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_CFLAGS_OPTIMIZE -MD -Zi
QMAKE_CFLAGS_DEBUG = -Zi -MDd
将三个MD都改成MT
QMAKE_CFLAGS_RELEASE = $$QMAKE_CFLAGS_OPTIMIZE -MT
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_CFLAGS_OPTIMIZE -MT -Zi
QMAKE_CFLAGS_DEBUG = -Zi -MTd
2.打开qtbase\mkspecs\features\qt_configure.prf
在defineTest(qtConfLibrary_inline)

lib = $$eval($${1}.library)
!defined($${1}.libs, var): \
error(“‘inline’ source in library ‘$$lib’ does not specify ‘libs’.”)
改成
lib = $$eval($${1}.library)
equals(lib, icu){
$${1}.libs = “-lsicudt -lsicuin -lsicuuc -lAdvapi32”
}
!defined($${1}.libs, var): \
error(“‘inline’ source in library ‘$$lib’ does not specify ‘libs’.”)
3.启动 x86 Native Tools Command Prompt for VS 2017
4.配置环境变量
SET PATH=E:\Build\QT\ICU\lib\;E:\Build\QT\OpenSSL\bin;%PATH%
SET INCLUDE=E:\Build\QT\ICU\include;%INCLUDE%
SET LIB=E:\Build\QT\ICU\lib;%LIB%
SET PATH=E:\Build\qt-5.9.1\qtbase\bin;E:\Build\qt-5.9.1\gnuwin32\bin;%PATH%
5.配置python环境变量
SET PATH=C:\Python27;%PATH%

6.configure -confirm-license -opensource -debug-and-release -static -force-debug-info -prefix E:\Build\QT -qt-sqlite -qt-pcre -qt-zlib -qt-libpng -qt-libjpeg -qt-freetype -nomake examples -nomake tests -opengl dynamic -openssl-linked -icu -platform win32-msvc OPENSSL_PREFIX=E:\Build\QT\OpenSSL OPENSSL_LIBS=”-lssleay32 -llibeay32 -lgdi32″ ICU_PREFIX=E:\Build\QT\ICU ICU_LIBS_DEBUG=”-lsicudtd -lsicuind -lsicuucd -lAdvapi32″ ICU_LIBS_RELEASE=”-lsicudt -lsicuin -lsicuuc -lAdvapi32″
7.nmake

Posted in Qt

发表评论

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据