1.安裝安裝 ActivePerl / Python / Ruby 、 VS2015。
ActivePerl: http://www.activestate.com/activeperl/downloads
Python: https://www.python.org/downloads/
Ruby: https://www.ruby-lang.org
2015本機以前安裝好了,用13編譯註意修改幾個變量就好了。
2.下載靜態編譯所需要的包
http://download.qt.io/development_releases/qt/5.7/5.7.0-beta/single/
下載完之後解壓縮到目錄:
列如:F:\qt-everywhere-opensource-src-5.7.0\qtbase\mkspecs\common
下修改msvc-desktop.conf文件。
修改爲:
3.Build
在qt-everywhere-opensource-src-5.7.0根目錄下新建qt-build.bat文件
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 "D:\Program Files\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_V140_SDK71_;%CL%
REM ********** 3rd party build tools binaries: ruby, perl, python **********
SET PATH=D:\DevelopPrograms\Ruby23-x64\bin;D:\DevelopPrograms\Perl64\bin;D:\DevelopPrograms\Python\Python36;%PATH%
REM ********** Set up qt source env **********
SET _ROOT=F:\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 -prefix "D:\DevelopPrograms\Qt\Qt5.7.0\5.7\Qt5.7.0-static-win32-vs2015" -qt-sql-sqlite -qt-sql-odbc -plugin-sql-sqlite -plugin-sql-odbc -qt-zlib -qt-libpng -qt-libjpeg -opengl desktop -qt-freetype -no-qml-debug -no-angle -nomake tests -nomake examples -skip qtquickcontrols -skip qtquickcontrols2 -skip qtsensors -skip qtdoc -skip qtwebkit
此處參考:http://www.cnblogs.com/bbxx111/p/5461069.html 具體解釋
cmd運行.bat文件
F:
cd qt-everywhere-opensource-src-5.7.0
qt-build.bat
Configure參數說明:
configure -confirm-license -opensource // 確認選擇開源協議
-prefix "D:\DevelopPrograms\Qt\Qt5.7.0\5.7\Qt5.7.0-static-win32-vs2015" // 安裝目錄
-opengl desktop // 指定openGL
-debug-and-release // 編譯debug和release版本
-static // 編譯靜態版本
-platform win32-g++ // 使用minGW編譯
-nomake demos // 不編譯demo(注:本例不可用)
-nomake examples // 不編譯示例
-nomake tests // 不測試
-mp // 多核編譯
-skip qtwebkit // 不編譯這個庫(很耗時間)
*attmping to skip non-existent module qtwebkit
我忽略了,可以繼續運行的,如果不行就去掉 -skip qtwebkit 。
之後
nmake
很久… 很久… 他們都說兩個小時,注意前面一定要檢查清楚,不然要返工,很麻煩的。
完成之後,複製到你的指定路徑。
nmake install
**
4.最後使用
打開工具–>選項,首先配置Qt Versions,在靜態庫下面找到qmake
然後,
注意編譯器和Qt版本一致,否則會有紅色的警告。
新建項目
就此結束了!
Fix Problem
1.提示qmlscene 未安裝
把原來的qmlscene (D:\DevelopPrograms\Qt\Qt5.7.0\5.7\mingw53_32\bin)Copy到當前靜態庫bin下(As:D:\DevelopPrograms\Qt\Qt5.7.0\5.7\Qt5.7.0-static-win32-vs2015\bin)。
2.error LNK2038: 檢測到“RuntimeLibrary”的不匹配項的解決辦法
**
參考的博客:
**
關於config,用minGW編譯Qt靜態庫參照個:http://www.kavenblog.com/?p=880
使用批處理 來編譯靜態庫:http://www.cnblogs.com/bbxx111/p/5461069.html
項目的配置:http://blog.csdn.net/wwkaven/article/details/37668859