一、官方源碼下載下傳,qt-creator-opensource-src-4.8.2.zip
1、官方github源碼
https://github.com/qt-creator/qt-creatorQt Creator源碼
https://github.com/qt-creator/qt-creator/tree/master/src/plugins/designerQt Creator的設計師插件
https://github.com/qt/qtbaseQt核心類源碼
https://github.com/qt/qttoolsQt工具類源碼
https://github.com/qt/qttools/tree/dev/src/designerQt設計師的源碼
https://github.com/qt/qttools/tree/dev/src/windeployqt依賴庫工具源碼
2、官方正式發行網站
http://download.qt.io/official_releases/qt/5.12/5.12.5/submodules/qttools-opensource-src-5.12.5.zip,裡面有Qt設計師的源碼
http://download.qt.io/official_releases/qtcreator/4.8/4.8.2/我們從這裡下載下傳準備要編譯的Qt Creator源碼
3、編譯聲明
編譯Qt設計師和編譯Qt Creator,都要確定使用的Qt版本與之配套,否則會出錯。
筆者的實踐是:
(1)使用Qt 5.12.5+MSVC 2017 32bit版本,可以成功編譯
qttools-opensource-src-5.12.5
qt-creator-opensource-src-4.8.2
(2)使用Qt 5.9.8+MSVC 2015 32bit版本,可以成功編譯
接下來的内容,就舉例(2)來講解。
二、IDE和編譯器準備
Qt Creator IDE和MSVC 2015編譯器組合使用(不想完整安裝VS2015)
三、編譯源碼qt-creator-opensource-src-4.8.2
其實Qt官方自己就是使用MSVC2015 32bit編譯Qt Creator IDE的。為什麼采用Visual Studio的msvc編譯器,而不是MinGW的gcc編譯器?因為前者比後者編譯速度更快。一般來說Windows下就是MinGW的gcc和Visual Studio的nmake,在Windows下推薦使用MSVC編譯器,能夠加快編譯速度。MinGW,其實它就是一個移植版本的GCC,的确是不如VC++快的。如果是其它平台,那麼編譯器可以換成LLVM的clang,那就快很多了。是以結論:在Windows平台還是盡量用MSVC編譯器!
我們現在就來使用QtCreator編譯QtCreator源碼。(#^.^#)說起來有點饒舌。
使用Qt Creator IDE打開源碼qt-creator-opensource-src-4.8.2檔案夾裡的qtcreator.pro,使用MSVC2015 32bit,開始編譯,結果失敗了,報錯:
jom: D:\temp\build-qtcreator-Desktop_Qt_5_9_8_MSVC2015_32bit-Debug\src\Makefile [sub-libs-make_first-ordered] Error 2
jom: D:\temp\build-qtcreator-Desktop_Qt_5_9_8_MSVC2015_32bit-Debug\Makefile [sub-src-make_first-ordered] Error 2
21:34:20: 程序"D:\Qt\Qt5.9.8\Tools\QtCreator\bin\jom.exe"退出,退出代碼 2 。
Error while building/deploying project qtcreator (kit: Desktop Qt 5.9.8 MSVC2015 32bit)
When executing step "Make"
然後在“建構和運作”,把“使用jom代替nmake”的勾選去掉。結果還是報錯:
cd D:\temp\build-qtcreator-Desktop_Qt_5_9_8_MSVC2015_32bit-Debug\src\libs\botan\build && python D:\temp\qt-creator-opensource-src-4.8.2\src\libs\botan\..\3rdparty\botan\configure.py --cc=msvc --cc-bin=cl --cpu=x86 --amalgamation --minimized-build --disable-shared --enable-modules=aes,aes_ssse3,auto_rng,bigint,block,cbc,ctr,des,dh,dsa,ec_group,ecdh,ecdsa,entropy,filters,hmac,mode_pad,pubkey,rsa,sha1,sha1_sse2,sha1_x86,sha2_32,sha2_32_x86,sha2_64,simd,system_rng,emsa_pkcs1,pbes2,pbkdf2 --without-documentation --link-method=hardlink --debug-mode --cxxflags="-nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew /wd4100 /wd4800 /wd4127 /wd4244 /wd4250 /wd4267 /wd4334 /wd4702 /wd4996 /D_ENABLE_EXTENDED_ALIGNED_STORAGE"
'python' 不是内部或外部指令,也不是可運作的程式
或批處理檔案。
NMAKE : fatal error U1077: 'cd' : return code '0x1'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\nmake.exe"' : return code '0x2'
NMAKE : fatal error U1077: 'cd' : return code '0x2'
21:19:02: 程序"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\nmake.exe"退出,退出代碼 2 。
于是,上網找資料,找到了官方的說法:
https://wiki.qt.io/Building_Qt_Creator_from_Git https://wiki.qt.io/Building_Qt_5_from_GitPlease also read README.md in the source tree.
我在\qt-creator-opensource-src-4.8.2\README.md,看到如下說明,看來編譯Qt Creator源碼需要安裝perl和Python解釋器。
## Compiling Qt Creator
Prerequisites:
* Qt 5.9.0 or later
* Qt WebEngine module for QtWebEngine based help viewer
* On Windows:
* ActiveState Active Perl
* MinGW with g++ 5.3 or Visual Studio 2015 or later
* jom
* Python 3.5 or later (optional, needed for the python enabled debug helper)
* On Mac OS X: latest Xcode
* On Linux: g++ 5.3 or later
* LLVM/Clang 6.0.0 or later (optional, needed for the Clang Code Model, see the
section "Get LLVM/Clang for the Clang Code Model")
* CMake (only for manual builds of LLVM/Clang)
* Python 2.6 or later (needed for building the bundled Botan library)
* Qbs 1.7.x (optional, sources also contain Qbs itself)
四、重整旗鼓,繼續
1、環境準備,安裝perl和python
https://www.activestate.com/products/perl/downloads/ActivePerl-5.28 x64
Typical安裝
Add perl to the PATH 勾選
perl -v
https://www.python.org/Add Python 3.6 to PATH勾選
自定義安裝,全選
Install for all users勾選
2、使用Qt Creator IDE,MSVC2015 32bit,打開源碼的qtcreator.pro,沒有什麼需要額外設定的,直接建構即可。
debug和release分别編譯,順利完成。(#^.^#)
歡迎通路我的另一篇部落格《在Windows和macOS平台,自主編譯Qt Creator和Qt Designer源碼》
-------
參考Qt的官方文獻
https://code.qt.io/cgit/qt-creator/qt-creator.git/tree/README.md