Building Qt Creator from Git: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
(Qt Creator now requires Qt 5.11)
(20 intermediate revisions by 15 users not shown)
Line 1: Line 1:
 
{{LangSwitch}}
 
[[Category:HowTo]]
[[Category:HowTo]]
[[Category:Developing_with_Qt::Qt 5]]
[[Category:Developing_with_Qt::Qt 5]]


'''English''' [[Building-Qt-Creator-from-Git-SimplifiedChinese|简体中文]]
== Dependencies ==


 
Please also read [http://code.qt.io/cgit/qt-creator/qt-creator.git/tree/README.md README.md] in the source tree.
 
= Building Qt Creator from git =
 
== Dependencies ==


To build Qt Creator from git, you need to first prepare some dependencies:
To build Qt Creator from git, you need to first prepare some dependencies:
* Qt libraries from Qt 5.3.1 (or newer) are needed. You can use one of the prebuilt packages from [http://qt.io/download the Downloads Page], or, if you want to go with git all the way, [http://wiki.qt.io/Building_Qt_5_from_Git compile Qt 5 from git] . These Qt modules are required: qtscript, qttools and qtdeclarative.
* Qt libraries from Qt 5.11.0 (or newer) are needed. You can use one of the prebuilt packages from [http://qt.io/download the Downloads Page], or, if you want to go with git all the way, [http://wiki.qt.io/Building_Qt_5_from_Git compile Qt 5 from git] . These Qt modules are required: qtscript, qttools and qtdeclarative.
* Optional: LLVM/Clang 6.0.0 or newer for the Clang Code Model related plugins.


If you have Qt installed, you probably have all the other dependencies of Qt Creator, too. There are numerous Qt Creator plugins, and they may require additional packages to be installed (but they usually don't block the compilation, so don't worry).
If you have Qt installed, you probably have all the other dependencies of Qt Creator, too. There are numerous Qt Creator plugins, and they may require additional packages to be installed (but they usually don't block the compilation, so don't worry).
Line 19: Line 15:
== Getting the source code ==
== Getting the source code ==


To get Qt Creator source code, type this. If you do not want to include the QBS (Qt Build Suite) plugin, you may omit —recursive:
To get Qt Creator source code, type this. If you do not want to include the Qbs plugin, you may omit <code>--recursive</code>:
<code>
<pre>
git clone —recursive https://git.gitorious.org/qt-creator/qt-creator.git
git clone --recursive https://code.qt.io/qt-creator/qt-creator.git
</code>
</pre>


This should be enough to compile Qt Creator from source. If you are interested in using other branches of the Qt Creator repository, please see the Qt Creator section at [http://wiki.qt.io/Branches Branch Guidelines].
This should be enough to compile Qt Creator from source. If you are interested in using other branches of the Qt Creator repository, please see the Qt Creator section at [http://wiki.qt.io/Branches Branch Guidelines].
Line 28: Line 24:
== Compiling Qt Creator ==
== Compiling Qt Creator ==


For building Qt Creator, an out-of-source build is recommended. For simplicity, this tutorial gives instructions for a build directory (namely 'qt-creator-build') that is located in parallel to the source directory ('qt-creator'), but any other folder can be used. If you have checked out '''QBS''', it will be compiled together with the rest of the code, you do not need to do anything special.
For building Qt Creator, an out-of-source build is recommended. For simplicity, this tutorial gives instructions for a build directory (namely 'qt-creator-build') that is located in parallel to the source directory ('qt-creator'), but any other folder can be used. If you have checked out '''Qbs''', it will be compiled together with the rest of the code, you do not need to do anything special.


Before you start with building, make sure you are using correct version of Qt. This can be done with the following command:
Before you start with building, make sure you are using correct version of Qt. This can be done with the following command:
<code>
<pre>
qmake -v
qmake -v
</code>
</pre>


If the output points to a wrong version of Qt, or returns an error, you need to show the qmake binary to your environment (it may also mean that something is wrong with your Qt installation). You need to modify your PATH environment variable to include the directory with the qmake executable, e.g. <Qt installation directory>/qtbase/bin.
If the output points to a wrong version of Qt, or returns an error, you need to show the qmake binary to your environment (it may also mean that something is wrong with your Qt installation). You need to modify your PATH environment variable to include the directory with the qmake executable, e.g. <Qt installation directory>/qtbase/bin.


<code>
In order to build the optional Clang Code Model plugin, you need to provide the path to the LLVM installation directory:
 
<pre>
export LLVM_INSTALL_DIR=/path/to/llvm (or "set" on Windows)
</pre>
 
Prepare the Makefile:
 
<pre>
mkdir qt-creator-build
mkdir qt-creator-build
cd qt-creator-build
cd qt-creator-build
qmake -r ../qt-creator/qtcreator.pro
qmake ../qt-creator/qtcreator.pro
</code>
</pre>


This will prepare the Makefile.
'''Note:''' Your build directory must be on the same path hierarchy level as your source directory. Other configurations are not supported by qmake in all cases. If you do not heed that rule, your Qt Creator build will fail to deploy its resources to the build directory, and you cannot run Qt Creator without installing it.
<pre>
-WRONG-: srcdir/
        builddir/debug/
-RIGHT-: srcdir/
        builddir-debug/
</pre>


'''Note:''' If you built qt5 from the git repository and you get an error like
'''Note:''' If you built qt5 from the git repository and you get an error like
Line 49: Line 59:
<code>Project ERROR: Unknown module(s) in QT: script</code>
<code>Project ERROR: Unknown module(s) in QT: script</code>


..then In your qt5 repository run:
..then In your qt5 build directory run:


<code>make module-qtscript</code>
<pre>make -j<number-of-cpu-cores+1> module-qtscript</pre>
 
Now back in your qt-creator build folder, you can configure and then compile qt creator:


Now, you can order the compilation:
On Linux, OS X:
On Linux, OS X:
<code>
<pre>
cd qt-creator-build
make qmake_all
make -j <number-of-cpu-cores+1>
make -j <number-of-cpu-cores+1>
</code>
</pre>
 
On Windows (MSVC):
On Windows (MSVC):
<code>
<pre>
nmake
nmake
</code>
</pre>


Compilation takes a while (only a bit less than compilation of Qt libraries themselves)- so be patient. After it's finished, you can safely start using Qt Creator (binaries are located in qt-creator-build/bin directory).
Compilation takes a while (only a bit less than compilation of Qt libraries themselves)- so be patient. After it's finished, you can safely start using Qt Creator (binaries are located in qt-creator-build/bin directory).
For themes, and therefore colors, to work correctly, you may have to install QT Creator (see next step).


== Installing Qt Creator (optional) ==
== Installing Qt Creator (optional) ==
Line 69: Line 85:
No further steps are required, but if you want to install it on your machine, type this:
No further steps are required, but if you want to install it on your machine, type this:
Linux:
Linux:
<code>
<pre>
make install INSTALL_ROOT=$INSTALL_DIRECTORY
make install INSTALL_ROOT=$INSTALL_DIRECTORY
</code>
</pre>
On Windows:
On Windows:
<code>
<pre>
nmake install INSTALL_ROOT=$INSTALL_DIRECTORY
nmake install INSTALL_ROOT=$INSTALL_DIRECTORY
</code>
</pre>


On OS X, just move the Qt Creator app bundle where you like.
On OS X, just move the Qt Creator app bundle where you like.

Revision as of 20:16, 10 August 2019

En Ar Bg De El Es Fa Fi Fr Hi Hu It Ja Kn Ko Ms Nl Pl Pt Ru Sq Th Tr Uk Zh

Dependencies

Please also read README.md in the source tree.

To build Qt Creator from git, you need to first prepare some dependencies:

  • Qt libraries from Qt 5.11.0 (or newer) are needed. You can use one of the prebuilt packages from the Downloads Page, or, if you want to go with git all the way, compile Qt 5 from git . These Qt modules are required: qtscript, qttools and qtdeclarative.
  • Optional: LLVM/Clang 6.0.0 or newer for the Clang Code Model related plugins.

If you have Qt installed, you probably have all the other dependencies of Qt Creator, too. There are numerous Qt Creator plugins, and they may require additional packages to be installed (but they usually don't block the compilation, so don't worry).

Getting the source code

To get Qt Creator source code, type this. If you do not want to include the Qbs plugin, you may omit

--recursive

:

git clone --recursive https://code.qt.io/qt-creator/qt-creator.git

This should be enough to compile Qt Creator from source. If you are interested in using other branches of the Qt Creator repository, please see the Qt Creator section at Branch Guidelines.

Compiling Qt Creator

For building Qt Creator, an out-of-source build is recommended. For simplicity, this tutorial gives instructions for a build directory (namely 'qt-creator-build') that is located in parallel to the source directory ('qt-creator'), but any other folder can be used. If you have checked out Qbs, it will be compiled together with the rest of the code, you do not need to do anything special.

Before you start with building, make sure you are using correct version of Qt. This can be done with the following command:

qmake -v

If the output points to a wrong version of Qt, or returns an error, you need to show the qmake binary to your environment (it may also mean that something is wrong with your Qt installation). You need to modify your PATH environment variable to include the directory with the qmake executable, e.g. <Qt installation directory>/qtbase/bin.

In order to build the optional Clang Code Model plugin, you need to provide the path to the LLVM installation directory:

export LLVM_INSTALL_DIR=/path/to/llvm (or "set" on Windows)

Prepare the Makefile:

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

Note: Your build directory must be on the same path hierarchy level as your source directory. Other configurations are not supported by qmake in all cases. If you do not heed that rule, your Qt Creator build will fail to deploy its resources to the build directory, and you cannot run Qt Creator without installing it.

-WRONG-: srcdir/
         builddir/debug/
-RIGHT-: srcdir/
         builddir-debug/

Note: If you built qt5 from the git repository and you get an error like

Project ERROR: Unknown module(s) in QT: script

..then In your qt5 build directory run:

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

Now back in your qt-creator build folder, you can configure and then compile qt creator:

On Linux, OS X:

cd qt-creator-build
make qmake_all
make -j <number-of-cpu-cores+1>

On Windows (MSVC):

nmake

Compilation takes a while (only a bit less than compilation of Qt libraries themselves)- so be patient. After it's finished, you can safely start using Qt Creator (binaries are located in qt-creator-build/bin directory).

For themes, and therefore colors, to work correctly, you may have to install QT Creator (see next step).

Installing Qt Creator (optional)

No further steps are required, but if you want to install it on your machine, type this: Linux:

make install INSTALL_ROOT=$INSTALL_DIRECTORY

On Windows:

nmake install INSTALL_ROOT=$INSTALL_DIRECTORY

On OS X, just move the Qt Creator app bundle where you like.