Chapter 2. Getting Started

In this chapter, we show how to use the kdesrc-build to checkout modules from the KDE repository and build them. We also provide a basic explanation of the KDE source code structure and the steps you have to perform before running the script.

All topics present in this chapter are covered with even more detail in the Build from Source article, at the KDE Community Wiki. If you are compiling KDE for the first time, it is a good idea to read it, or consult it as a reference source. You will find detailed information about packaging tools and requirements, common compilation pitfalls and strategies and information about running your new KDE installation.

Preparing the System to Build KDE

Setup a new user account

It is recommended that you use a different user account to build, install, and run your KDE software from, since less permissions are required, and to avoid interfering with your distribution's packages. If you already have KDE packages installed, the best choice would be to create a different (dedicated) user to build and run the new KDE.

Tip

Leaving your system KDE untouched also allows you to have an emergency fallback in case a coding mistake causes your latest software build to be unusable.

You can do also setup to install to a system-wide directory (e.g. /usr/src/local) if you wish. This document does not cover this installation type, since we assume you know what you are doing.

Ensure your system is ready to build KDE software

Before using the kdesrc-build script (or any other building strategy) you must install the development tools and libraries needed for KDE. The nearly complete list of required tools can be found from the KDE Community Wiki Build Requirements page.

Here is a list of some of the things you will need:

  • You will need CMake, this software is what KDE uses to handle build-time configuration of the source code and generation of the specific build commands for your system. The required version will vary depending on what versions of KDE software you are building (see TechBase for specifics), but with modern distributions the CMake included with your distribution should be quite sufficient.

  • You must also install the source control clients needed to checkout the KDE source code. This means you need at least the following:

    • The Git source control manager, which is used for all KDE source code

    • Although it is not required, the Bazaar source control manager is used for a single module (libdbusmenu-qt) that is required for the KDE libraries. Most users can install this library through their distribution packages but kdesrc-build supports building it as well if you desire. But to build libdbusmenu-qt, you must have Bazaar installed.

  • The Perl scripting language is required for kdesrc-build, some KDE repositories, and Qt™ (if you build that from source).

    The Perl that comes with your distribution should be suitable (it needs to be at least Perl 5.14), but you will also need some additional modules (kdesrc-build will warn if they are not present):

    • IO::Socket::SSL

    • JSON::PP or JSON::XS

    • YAML::PP, YAML::XS, or YAML::Syck

  • You will need a full C++ development environment (compiler, standard library, runtime, and any required development packages). The minimum required versions vary based on the KDE module: the KDE Frameworks 5 collection supports the oldest compilers, while KDE Plasma 5 and KDE Applications tend to require more recent compilers.

    The GCC 4.8 or Clang 4 compilers are the minimum recommended. Many distributions support easily installing these tools using a build-essentials package, an option to install "build dependencies" with Qt™, or similar features. The KDE Community Wiki has a page tracking recommended packages for major distributions.

  • You will need a build tool that actually performs the compilation steps (as generated by CMake). GNU Make is recommended and should be available through your package manager. CMake does support others options, such as the "ninja" build tool, which can be used by kdesrc-build using the custom-build-command configuration file option.

  • Finally, you will need the appropriate Qt™ libraries (including development packages) for the version of KDE software you are building. kdesrc-build does not officially support building Qt™ 5 (the current major version), so it is recommended to use your distribution's development packages or to see the KDE Community wiki page on self-building Qt 5.

Note

Most operating system distributions include a method of easily installing required development tools. Consult the Community Wiki page Required devel packages to see if these instructions are already available.

Important

Some of these packages are divided into libraries (or programs or utilities), and development packages. You will need at least the program or library and its development package.

Setup kdesrc-build

Install kdesrc-build

The KDE developers make frequent changes to kdesrc-build to keep it in sync with advances in KDE development, including improvements to the recommended kdesrc-build configuration, added modules, improving CMake flags, etc.

Because of this, we recommend obtaining kdesrc-build directly from its source repository and then periodically updating it.

You can obtain kdesrc-build from its source repository by running:

$ git clone https://anongit.kde.org/kdesrc-build ~/kdesrc-build

Replace ~/kdesrc-build with the directory you would like to install to.

You can update kdesrc-build later by running:

$ cd ~/kdesrc-build
$ git pull

Tip

We recommend adding the kdesrc-build installation directory to your PATH environment variable, so that you can run kdesrc-build without having to fully specify its path every time.

Prepare the configuration file

kdesrc-build uses a configuration file (located at ~/.kdesrc-buildrc) to control which modules are built, where they are installed to, etc.

You can use a program included with kdesrc-build, called kdesrc-build-setup in order to prepare a simple kdesrc-build configuration. You can then edit the ~/.kdesrc-buildrc from there to make any changes you see fit.

kdesrc-build-setup itself runs from a terminal (instead of using a graphical interface), just like kdesrc-build, so you can use it even if you have no graphical interface available yet.

Manual setup of configuration file

You can also setup your configuration file manually, by copying the included sample configuration file kdesrc-buildrc-kf5-sample to ~/.kdesrc-buildrc and then editing the file. Chapter 4, Configuring kdesrc-build will be a useful reference for this, especially its table of configuration options.

kdesrc-build contains many recommended configuration files to support KDE Frameworks 5, Plasma™ 5, and other KDE applications. The kdesrc-build-setup refers to these files in the configuration file it generates, but you can also use them yourself. See the section called “Including other configuration files” for information on how to use other configuration files from your own ~/.kdesrc-buildrc.

You can find more information about the syntax of the configuration file in the section called “Setting the Configuration Data” and in Chapter 4, Configuring kdesrc-build.