Nova Flow OS
KDE Developer Platform
KDE Developer Platform
  • KDE Developer Platform
    • Getting started
      • Building KDE software
        • KDE software
        • Where to find the development team
        • Learning more
        • Choose what to work on
        • Source code cross-referencing
        • Installing build dependencies
        • Set up a development environment
        • Building KDE software with kdesrc-build
        • Basic troubleshooting
        • Tips and tricks
        • IDE Configuration
          • Setting up an IDE for KDE development
          • Visual Studio Code
          • Qt Creator
          • Kate
          • KDevelop
          • CLion
          • Sublime Text
        • Building KDE software manually
        • Building KDE software with distrobox and podman
      • Kirigami
        • KDE is ours
        • Setting up and getting started
        • Explaining pages
        • Layouts, ListViews, and Cards
        • Adding actions
        • Adding a dialog
        • Using separate files
        • Next steps
        • Colors and themes in Kirigami
        • Typography
        • Actions based components
        • Page rows and page stacks
        • Scrollable pages and list views
        • Cards
        • Drawers
        • Chips
        • Dialog types
        • Controls and interactive elements
        • Form layouts
        • Inline messages
        • Action toolbars
        • Progress bars and indicators
        • List views
        • Understanding CMakeLists
        • Figuring out main.cpp
        • Connect logic to your QML user interface
        • Connect models to your QML user interface
        • About page
        • Introduction to Kirigami Addons
        • FormCard About pages
        • Form delegates in your settings pages
      • KXmlGui
        • Getting started with KXmlGui
        • Hello World!
        • Creating the main window
        • Using actions
        • Saving and loading
        • Command line interface
      • Python with Kirigami
        • Apps with QML and Python
        • Your first Python + Kirigami application
        • Creating a Python package
        • Creating a Flatpak
      • Common programming mistakes
      • Adding a new KDE project
    • Features
      • Icons
      • Configuration
        • The KConfig Framework
        • Introduction to KConfig
        • Using KConfig XT
        • KDE Frameworks 6 porting guide
        • Settings module (KCM) development
        • KConfigDialog
      • D-Bus
        • What is D-Bus practically useful for?
        • Introduction to D-Bus
        • Accessing D-Bus interfaces
        • Intermediate D-Bus
        • Creating D-Bus interfaces
        • Using custom types with D-Bus
        • D-Bus autostart services
      • Create your own mouse cursor theme
      • Session management
      • Archives
      • Desktop file
      • KAuth
        • Privilege Escalation
        • Using actions in your applications
      • KIdleTime
      • Akonadi: personal information management
        • Debugging Akonadi Resources
        • Using Akonadi in applications
      • Concurrent programming
      • Solid
      • Sonnet
    • Plasma themes and plugins
      • Getting started
      • Plasma Widget tutorial
        • How to create a plasmoid
        • Setup
        • Porting Plasmoids to KF6
        • Testing
        • QML
        • Plasma's QML API
        • Widget Properties
        • Configuration
        • Translations / i18n
        • Examples
        • C++ API
      • KWin Effects
      • Plasma Desktop scripting
        • Javascript Interaction With Plasma Shells
        • Templates
        • Examples
        • API documentation
        • Configuration keys
      • Plasma Style tutorial
        • Creating a Plasma Style quickstart
        • Understanding Plasma Styles
        • SVG elements and Inkscape
        • Background SVG format
        • System and accent colors
        • Theme elements reference
        • Porting themes to Plasma 5
        • Porting themes to Plasma 6
      • Aurorae window decorations
      • KWin scripting tutorial
        • Quick start
        • KWin scripting API
      • Wallpapers
      • Plasma comic
        • Tutorial
        • Testing and debugging
        • Examples
      • Create a custom Window Switcher
      • KRunner C++ Plugin
        • Basic Anatomy of a Runner
        • KRunner metadata format
    • Applications
      • Creating sensor faces
      • Dolphin
        • Creating Dolphin service menus
      • Kate
        • Kate plugin tutorial
      • KMines
        • Making a KMines theme
      • Writing tests
        • Appium automation testing
    • Packaging
      • Android
        • KDE on Android
        • Building applications for Android
        • Packaging and publishing applications for Android
        • Publishing on Google Play
          • Introduction
          • Packaging your app
          • Adding your app to Google Play
          • Publishing your app
          • Releasing new versions of old apps
        • Porting applications to Android
          • Basic porting
          • Making applications run well on Android
          • Metadata
      • Windows
        • Packaging and publishing applications for Windows
        • Publish your app in the Microsoft Store
          • Packaging your app for the Microsoft Store
          • Submitting your app to the Microsoft Store
      • Plasma Mobile
        • KDE on mobile devices
        • Porting a new device to Plasma Mobile
        • KDE Telephony stack
          • General Overview
          • Kernel layer
          • System daemons
            • General overview
            • Developing Telephony functionality
            • ModemManager Telephony functions
          • Session daemons
          • QML declarative plugin layer
          • KDE application layer
        • Execute applications
      • Distributing KDE software as Flatpak
        • Your first Flatpak
        • Extending your package
        • Nightly Flatpaks and Flathub
        • Testing your Flatpak
    • System administration
      • Shell scripting with KDE dialogs
      • Kiosk: Simple configuration management for large deployment
        • Abstract
        • Introduction to Kiosk
        • Kiosk keys
    • Contribute to the documentation
    • About
      • Readme
      • License
        • Creative Commons Attribution-ShareAlike 4.0 International
        • GNU General Public License 3.0 or later
Powered by GitBook
On this page
  • Install git
  • Configure git
  • Set up kdesrc-build
  • Next Steps
  1. KDE Developer Platform
  2. Getting started
  3. Building KDE software

Set up a development environment

Installing and configuring kdesrc-build

PreviousInstalling build dependenciesNextBuilding KDE software with kdesrc-build

Last updated 8 months ago

Source code for KDE software lives on . 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 .

If you're not familiar with the command line interface, you can . 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 .

The tool we will be using here for setting up a development environment and building KDE software is . 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:

| , |

sudo apt install git

| | ---------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | | , |

sudo pacman -S git

| | |

sudo zypper install git

| | |

sudo dnf install git perl perl-IPC-Cmd perl-MD5 perl-FindBin

|

Configure git

We then need to set your authorship information properly so that any changes you make can be properly attributed to you:

git config --global user.name "Your Name"
git config --global user.email "you@email.com"

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.

For convenience, we can enable a feature that will later become useful when we start pushing code to a repository branch:

git config --global push.autoSetupRemote true

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

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:

mkdir -p ~/kde
mkdir -p ~/.local/share
cd ~/.local/share
git clone https://invent.kde.org/sdk/kdesrc-build.git
cd kdesrc-build

And create a symlink to make kdesrc-build accessible in your $PATH:

mkdir -p ~/.local/bin
ln -sf ~/.local/share/kdesrc-build/kdesrc-build ~/.local/bin

About ~/.local/bin

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):

export PATH=$PATH:~/.local/bin

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:

Click here to see how to enable source repos

KDE neon/Debian/Ubuntu/Kubuntu/etc:

If the file /etc/apt/sources.list exists

deb http://us.archive.ubuntu.com/ubuntu/ noble main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ noble main restricted

Note: The URL might differ depending on your country, and instead of noble the name of the Debian or Ubuntu version should appear instead, like bookworm or jammy.

If the deb-src line is commented out with a #, remove the # character.

Lastly, run:

sudo apt update

If the file /etc/apt/sources.list does not exist

Starting with Kubuntu 24.04, the configuration file for apt repositories has moved to /etc/apt/sources.list.d/ubuntu.sources.

Types: deb
URIs: http://archive.ubuntu.com/ubuntu
Suites: noble noble-updates noble-backports
Components: main universe restricted multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

With:

Types: deb deb-src
URIs: http://archive.ubuntu.com/ubuntu
Suites: noble noble-updates noble-backports
Components: main universe restricted multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

Note: The URL might differ depending on your country, and instead of noble the name of the Debian or Ubuntu version should appear instead, like bookworm or jammy.

Lastly, run:

sudo apt update

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:

kdesrc-build --initial-setup

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:

# Go to where kdesrc-build was cloned:
cd ~/.local/share/kdesrc-build
# Update kdesrc-build itself:
git pull
# Install new distribution package dependencies, if any:
kdesrc-build --install-distro-packages

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:

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:

  1. You installed and configured git.

  2. You cloned kdesrc-build using git.

  3. You ran the initial setup for kdesrc-build.

Time to learn how to use kdesrc-build to build software from source code!

If they don't match, then the BUG: and FEATURE: keywords won't work (see for more information).

Next, in order to authenticate yourself when pushing code changes, you need to add an ssh key to your GitLab profile as . Once you are done, we can start using kdesrc-build.

For example, the KDE application depends on more than 20 other KDE libraries as well as the Qt toolkit.

Some Linux distributions do not provide development packages for 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).

Some Linux distributions might not follow the 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.

Open the file /etc/apt/sources.list with a text editor such as or nano. Each line that starts with "deb " should be followed by a similar line beginning with "deb-src ", for example:

Open the file /etc/apt/sources.list.d/ubuntu.sources with an editor like or nano. Change the contents of the file by replacing all occurrences of Types: deb with Types: deb deb-src. For example, replacing 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 repository to include the needed packages in the list.

Use one of the alternative build methods mentioned in

Switch distros to something either as the primary operating system or in a virtual machine

KDE Invent
Konsole
find tutorials here
video tutorials about setting up kdesrc-build
kdesrc-build
Kubuntu
KDE Neon
Manjaro
Arch
OpenSUSE
Fedora
this page
described here
KCalc
KDE Frameworks
Freedesktop Base Directory Specification
Kate
Kate
repo-metadata/distro-dependencies
Building KDE software
Build Qt6 using kdesrc-build
Install Qt6 using the Qt online installer
better suited for building KDE software from source code
The Search field in System Settings