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.


Leaving your system KDE untouched also allows you to have an emergency fallback in case a compiled KDE is unstable for whatever reason.

Later, you can do a system installation if you wish. This document does not cover a system installation. If you are performing a system wide install, you should already know what you are doing. If not, then you may want to consult the documentation, or help sites, for your distribution in order to prepare and use the system installation correctly.

Ensure your system is ready to build KDE source

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. The required version will vary depending on what version of KDE 4 you are building, see TechBase for specifics, however a good bet is to have the most recent available version. CMake is the program used by kdesrc-build to handle the actual configuration and build steps for the vast majority of KDE software.

  • You must also install the client software used to checkout the KDE source code. This means you need at least the following:

    • Subversion, which used to be the only source code manager in use, and is still used for some modules with large data files. You can check if you have it by running svn --version.

    • You will need the Git source control manager installed as well, for KDE's git-based projects.

    • 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.

  • You will need a full C++ development environment. GCC 4.6 or later is recommended.

  • Finally, you will need a make tool. GNU Make is recommended and should be available through your package manager. After cmake has been run by kdesrc-build, make handles actually running the build process, which is why it is required.


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.

One exception to the required libraries is the Qt™ library. kdesrc-build will normally install a copy of Qt™ whether you have it installed or not, so it is not necessary for you to have it. If you do not want to use the Qt™ copy, you need to do these things:

  • Make sure to remove the qt module from your configuration file, as you will not need it, and having it would add extra time to your build.

  • Change the setting of the qtdir option in your configuration file to point to your system Qt™. The location of your system Qt™ can be found by running qmake -query QT_INSTALL_PREFIX.


    The qmake command might be called qmake4 or qmake-qt4 on your distribution.

  • If you do not already have Qt™ installed, install it, including any relevant -dev or -devel packages. You will need at least Qt™ 4.7 if you are building KDE 4.


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. The libraries you need will change depending on the modules you intend to build, as each module has its own requirements. The KDE Community wiki has more details about the specific tools and techniques used to install and find the required software.

Setup kdesrc-build

Install kdesrc-build

You probably already have a version of the kdesrc-build script installed in your system. However, if you do not, you can download it from kdesrc-build home page, or you can find it from its home in the KDE source repository.


If you use a more recent kdesrc-build by downloading from its website, you should remember to run the kdesrc-build script you downloaded. You can use the --version option to kdesrc-build as a quick way to verify this.

  1. To download kdesrc-build from its home page, simply go to the kdesrc-build home page and download the latest appropriate release. The release is packaged as a compressed tarball archive, which you can extract using Ark or tar. The contents of the archive include the actual kdesrc-build script, a sample configuration file (kdesrc-buildrc-sample), and a quick-setup program.

  2. Or, you can obtain kdesrc-build from its source repository, by running:

    $ git clone git:// ~/kdesrc-build

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

No matter which technique you use, you need to make sure that the kdesrc-build file is executable. For convenience you should make sure it is in a directory contained in the PATH environment variable, otherwise you may get messages saying that the command was not found, or you may run a previously-installed version by mistake.

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.


You can use the included kdesrc-buildrc-sample sample configuration to get explanations as to the various options available.

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.