一、官方源码下载,qt-creator-opensource-src-4.8.2.zip
1、官方github源码
https://github.com/qt-creator/qt-creator Qt Creator源码
https://github.com/qt-creator/qt-creator/tree/master/src/plugins/designer Qt Creator的设计师插件
https://github.com/qt/qtbase Qt核心类源码
https://github.com/qt/qttools Qt工具类源码
https://github.com/qt/qttools/tree/dev/src/designer Qt设计师的源码
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版本,可以成功编译
qt-creator-opensource-src-4.8.2
接下来的内容,就举例(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'
Stop.
NMAKE : fatal error U1077: 'cd' : return code '0x2'
Stop.
NMAKE : fatal error U1077: 'cd' : return code '0x2'
Stop.
NMAKE : fatal error U1077: 'cd' : return code '0x2'
Stop.
21:19:02: 进程"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\nmake.exe"退出,退出代码 2 。
Error while building/deploying project qtcreator (kit: Desktop Qt 5.9.8 MSVC2015 32bit)
When executing step "Make"
于是,上网找资料,找到了官方的说法:
https://wiki.qt.io/Building_Qt_Creator_from_Git
https://wiki.qt.io/Building_Qt_5_from_Git
Please 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
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://wiki.qt.io/Building_Qt_Creator_from_Git
https://code.qt.io/cgit/qt-creator/qt-creator.git/tree/README.md