Set up a development environment
Installing and configuring kdesrc-build
Source code for KDE software lives on KDE Invent. But before you can work on it, you'll need to set up a development environment: a set of tools that allows you to access and edit the source code, compile it into a form that the computer can run, and deploy it to a safe location. To accomplish these tasks, you will need to enter commands using a terminal program, such as KDE's Konsole.
If you're not familiar with the command line interface, you can find tutorials here. However, advanced command line skills are not required, and you will learn what you need along the way!
If you're a visual learner, we also provide video tutorials about setting up kdesrc-build.
The tool we will be using here for setting up a development environment and building KDE software is kdesrc-build. It will let you set up your development environment and compile applications on Linux and FreeBSD.
Keep in mind
You only need to set up your environment once, and then you will be able to compile (and recompile) KDE software as often as needed later on!
Install git
Setting up your environment on a Linux machine is fairly simple. First you will need to use your operating system's package manager to install git:
| | ---------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | | Manjaro, Arch |
| | OpenSUSE |
| | Fedora |
|
Configure git
We then need to set your authorship information properly so that any changes you make can be properly attributed to you:
The name you provide should be your actual name, not your KDE Identity username or a pseudonym.
The email address must be the same as the email address used for your https://bugs.kde.org account.
If they don't match, then the BUG:
and FEATURE:
keywords won't work (see this page for more information).
For convenience, we can enable a feature that will later become useful when we start pushing code to a repository branch:
Next, in order to authenticate yourself when pushing code changes, you need to add an ssh key to your GitLab profile as described here. Once you are done, we can start using kdesrc-build
.
Set up kdesrc-build
kdesrc-build
is the official KDE meta build system tool. It is used to manage the building of many software repositories in an automated fashion.
Its primary purpose is to manage dependencies. Every software has dependencies: other pieces of software that provide lower-level functionality they rely on. In order to compile any piece of software, its dependencies must be available.
KDE software has two types of dependencies:
dependencies on other pieces of KDE software
dependencies on 3rd-party software
For example, the KDE application KCalc depends on more than 20 other KDE libraries as well as the Qt toolkit.
Some Linux distributions do not provide development packages for KDE Frameworks and of other libraries that are up-to-date enough for us to build from the "main" branch of the KDE git repositories (the branch where the development of the next software versions takes place), so we use kdesrc-build
to compile them ourselves. The goal is to avoid using KDE binaries, KDE libraries and other KDE files from the operating system where possible (in the Linux case, these files reside in the /usr
directory).
Let's set it up now! You will need many gigabytes of free disk space. Budget 50 GB for KDE Frameworks + KDE Plasma, and 10-30 GB more for some apps as well. Then clone the kdesrc-build
git repository in the following directory:
And create a symlink to make kdesrc-build
accessible in your $PATH
:
About ~/.local/bin
Some Linux distributions might not follow the Freedesktop Base Directory Specification that enforces that the ~/.local/bin
directory be added to the $PATH
, which is required for an executable to show up in the terminal without its absolute path.
To check if ~/.local/bin
is in the $PATH
, run: echo $PATH
.
If the directory is not listed, then you will need to add it yourself. You can do so by adding the following to your ~/.bashrc
(or equivalent in your preferred shell):
Closing and reopening your terminal window once should be enough for kdesrc-build
to appear for the next steps.
Don't forget to warn your distribution to follow the specification.
Note
Some distros need source repositories enabled before you can install the development packages you need. Do that now, if needed:
Initial setup
With that done, it's time to run the initial setup program, which will install the necessary binary packages from your Linux operating system:
The step kdesrc-build --initial-setup
above installs the Linux binary packages that are needed for kdesrc-build to build all of KDE Frameworks and then creates a default configuration file ~/.config/kdesrc-buildrc
. If you look at that configuration file, you will see that by default kdesrc-build will compile everything inside a new ~/kde
folder for you. You will see that in the next page.
Updating kdesrc-build
Once in a while you will want to update kdesrc-build to get its latest changes. To do so, run the following:
If you discover any external dependencies needed to build KDE software that were not installed with kdesrc-build --initial-setup
or kdesrc-build --install-distro-packages
, then please send a merge request to the repo-metadata/distro-dependencies repository to include the needed packages in the list.
Set up Qt
Qt is the fundamental framework that is needed for pretty much all KDE development. A recent enough version of Qt 6, currently Qt version greater or equal to 6.7, is required to proceed.
The initial setup of kdesrc-build should have installed the required Qt6 packages for you already.
If your Linux distribution does not provide recent versions of Qt packages, you have four options:
Use one of the alternative build methods mentioned in Building KDE software
Switch distros to something better suited for building KDE software from source code either as the primary operating system or in a virtual machine
Disable indexing for your development environment
You'll want to disable indexing for your development-related git repos and the files they will build and install.
To do that, add the ~/kde
directory to the exclusions list in System Settings › Search › File Search > Stop Indexing a Folder...
Next Steps
Your development environment is now set up and ready to build software.
To recapitulate the essentials:
You installed and configured git.
You cloned kdesrc-build using git.
You ran the initial setup for kdesrc-build.
Time to learn how to use kdesrc-build to build software from source code!
Last updated