Building Qt Creator from Git/zh: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
(Add "cleanup" tag)
Line 1: Line 1:
{{Cleanup | reason=Auto-imported from ExpressionEngine.}}
[[Category:HowTo]]
[[Category:HowTo]]
[[Category:Developing_with_Qt::Qt 5]]
[[Category:Developing_with_Qt::Qt 5]]

Revision as of 15:10, 3 March 2015

This article may require cleanup to meet the Qt Wiki's quality standards. Reason: Auto-imported from ExpressionEngine.
Please improve this article if you can. Remove the {{cleanup}} tag and add this page to Updated pages list after it's clean.

简体中文 English

[toc align_right="yes" depth="2"]

在git中构建Qt Creator

依赖的库

为了在git中构建Qt Creator,你需要首先准备好某些依赖库:

如果你已经有安装好的Qt,你或许也已经有了必备的Qt Creator依赖库。Qt Creator同时有很多插件,这些插件或许也需要额外的依赖库。 (不用担心,这些依赖不会阻塞Qt Creator的编译)。

获取源代码

使用下面的命令来获取Qt Creator的源代码。如果你不需要包含QBS (Qt Build Suite) 插件,你可以忽略 —recursive:

git clone recursive git@gitorious.org:qt-creator/qt-creator.git
cd qt-creator

对于从源代码开始编译Qt Creator,这些已经足够。如果你有兴趣使用Qt Creator仓库的其它分支,可以参考"Branch Guidelines":http://wiki.qt.io/Branches.

编译Qt Creator

推荐使用外部构建(out-of-source build )来编译Qt Creator, 为简单起见,这篇教程使用了一个靠近源代码目录的路径,但你要知道,任何其它路径都是可以的。如果你已经检出 QBS ,它将和其它的代码一起编译,你不需要做什么特别的。

在编译之前,确保你使用的是正确的Qt版本。可以使用如下命令来验证:

qmake -v

如果输出指向的是错误版本的Qt,或者直接输出错误,你需要在环境中设置你的qmake的路径(这可能同时意味着你的Qt安装可能出现了某些错误)。 你需要修改PATH 来指向 <Qt installation directory>/bin/qmake (对于Qt4来说) 或者 <Qt installation directory>/qtbase/bin/qmake (对于Qt5来说)。

mkdir qt-creator-build
cd qt-creator-build
qmake -r ../qt-creator/qtcreator.pro

这将会生成Makefile。现在,你可以开始编译了: 在Linux, Mac上:

make -j <number-of-cpu-cores+1>

在Windows (MSVC)上:

nmake

编译需要一段时间 (仅仅比编译Qt库少一点)- 所以耐心点。编译结束后,你可以开始使用Qt Creator (生成的二进制文件位于 qt-creator-build/bin 目录)。

安装Qt Creator (可选)

实际上不需要再做什么了,但是如果你想安装Qt Creator到你的计算机上,可以使用如下命令:

在Linux, Mac上:

make install INSTALL_ROOT=$INSTALL_DIRECTORY

在Windows上:

nmake install INSTALL_ROOT=$INSTALL_DIRECTORY