靜態編譯 Qt5.7.0 (含 openssl 支持)

關於Qt靜態便宜的環境等,請先參見 Win10 + VS2015 下編譯 Qt5.6.0 。html

首先編譯 openssl 。我這裏用的版本是 openssl 1.0.2j (新的1.1版本的便宜稍有不一樣,詳見 openssl 的文檔)。openssl編譯的bat腳本以下:python

REM Initialize env for msvc 2015 cl compiler
SET PATH=C:\Windows;C:\Windows\system32
REM Set up \Microsoft Visual Studio 2015, where <arch> is amd64, x86, etc.
CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86

REM Update include & lib to support xp win sdk 7.1A
SET PATH=C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin;%PATH%
SET INCLUDE=C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include;%INCLUDE%
SET LIB=C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib;%LIB%
SET CL=/D_USING_V120_SDK71_;%CL%

SET PERL_DIR=C:\Perl64

SET PATH=%PERL_DIR%\bin;%PATH%

perl configure VC-WIN32 no-asm --prefix=d:/openssl/dir
ms\do_ms

nmake -f ms\nt.mak
nmake -f ms\nt.mak install

 

而後更改Qt的編譯腳本,便宜時引入openssl:git

REM ********** Initialize env for msvc 2015 cl compiler **********
SET PATH=C:\Windows;C:\Windows\system32
REM Set up \Microsoft Visual Studio 2015, where <arch> is amd64, x86, etc.
CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86

REM ********** Update include & lib to support xp win sdk 7.1A **********
SET PATH=C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin;%PATH%
SET INCLUDE=C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include;%INCLUDE%
SET LIB=C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib;%LIB%
SET CL=/D_USING_V120_SDK71_;%CL%

REM ********** OpenSSL 1.0.2 **********
SET OPENSLLDIR=D:\CollabPDF\windows\vendors\openssl
SET PATH=%OPENSLLDIR%\bin;%PATH%
SET INCLUDE=%OPENSLLDIR%\include;%INCLUDE%
SET LIB=%OPENSLLDIR%\lib;%LIB%

REM ********** 3rd party build tools binaries: ruby, perl, python ********** 
SET PATH=C:\Ruby22-x64\bin;C:\Perl64\bin;C:\Python27;%PATH%

REM ********** Set up qt source env **********
SET _ROOT=E:\qt-everywhere-opensource-src-5.7.0
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 QMAKESPEC=win32-msvc2015
SET _ROOT=

REM Generate makefile
configure.bat -confirm-license -opensource -platform win32-msvc2015 -debug-and-release -static -target xp -prefix D:\Qt\Qt5.7.0-static-win32-vs2015-xp -qt-sql-sqlite -qt-sql-odbc -plugin-sql-sqlite -plugin-sql-odbc -qt-zlib -qt-libpng -qt-libjpeg -opengl desktop -qt-freetype -openssl-linked OPENSSL_LIBS="-lssleay32 -llibeay32 -lgdi32 -luser32" -no-qml-debug -no-angle -nomake tests -nomake examples -mp

 

其餘問題:sql

  1. 我第一次嘗試使用 openssl 1.1 配合qt進行編譯,但報了一個錯。猜想多是由於openssl 1.1版本去除了sslv2支持。因此又改成使用openssl 1.0.2了。
  2. OPENSSL_LIBS須要引用 gdi32。由於openssl中用到了其中的函數(我沒有實際測試是否須要user32,編譯太慢,以防萬一也加上了)。
相關文章
相關標籤/搜索