Get Involved/development/More: Difference between revisions

From KDE Community Wiki
(→‎Option 2. distrobox: Moved to Develop)
 
(189 intermediate revisions by 17 users not shown)
Line 1: Line 1:
This page is the continuation with more advanced topics of the page [[Get_Involved/development]].
This page is the continuation with more advanced topics of the page [[Get_Involved/development]].


This paged is not meant for people that are starting to program for KDE.
== kde-builder is an alternative to kdesrc-build ==
 
kdesrc-build and kde-builder are two KDE build frameworks. They are used at the command line and have identical command line syntax, just replace the string "kdesrc-build" with "kde-builder". They use the same configuration file, named <code>kdesrc-buildrc</code>.
 
kde-builder is newer and regularly gets new features and is written in Python.
 
kdesrc-build is in maintenance mode and feature frozen and written in Perl.
 
The "how to install kde-builder" procedure is here https://invent.kde.org/sdk/kde-builder/-/blob/master/README.md .


== Develop in a Linux container ==
== Develop in a Linux container ==


When you start programming for KDE, it is recommended that you [[Get_Involved/development|use kdesrc-build in your main operating system or in a virtual machine]] running on a rolling-release Linux distribution (Arch, openSUSE Tumbleweed, KDE neon) or running on e.g. the latest version of Fedora KDE Spin or Kubuntu.
When you start programming for KDE, it is recommended that you [[Get_Involved/development|use kdesrc-build in your main operating system or in a virtual machine]] running on a [[Get_Involved/development#Operating_system|Linux operating system that is better supported by kdesrc-build]].


As an alternative, you can run kdesrc-build in a Linux container (docker, podman, toolbx, distrobox).
As an alternative, you can run kdesrc-build in a Linux container (docker, podman, toolbx, distrobox).
Line 15: Line 23:
=== Option 2. distrobox ===
=== Option 2. distrobox ===


Or, you can just create a long lived (pet not cattle) container using distrobox and podman (or docker). See https://www.youtube.com/watch?v=9JEALbcmcCg https://github.com/89luca89/distrobox
It is possible to start developing KDE software using container images that are able to see inside your home folder. This can be done using distrobox and podman.
 
This solution is particularly useful for users on immutable distributions like Fedora Kinoite, openSUSE Kalpa or the Steam Deck's SteamOS.


Start with the official Docker hub container image of one of the Linux distributions that is better suited for kdesrc-build. Then setup kdesrc-build in the container. distrobox makes it such that you can run GUI apps in the container. Also, your user's home directory (~) is the same in the host operating system and in the container. Warning: the container will write to your home directory and may conflict with your host operating system.
To learn how to build KDE software with distrobox, see: https://develop.kde.org/docs/getting-started/building/containers-distrobox/


== Other operating systems ==
== Other operating systems ==


=== FreeBSD ===
=== Kubuntu >= 23.10 ===


Install the latest release of FreeBSD with KDE Plasma Desktop on your hardware computer or in a virtual machine. Then set up kdesrc-build using the same procedure as when installing kdesrc-build on a Linux operating system. FreeBSD is currently supported by kdesrc-build. See https://www.youtube.com/watch?v=v2wq0eTnUuc https://www.youtube.com/watch?v=MT-AN4J-hn8
The default configuration of kdesrc-build requires Qt version 6.6. Kubuntu 23.10 and 24.04 have Qt version 6.4.2. It is recommended that you use a [[Get_Involved/development#Operating_system|Linux OS that is better supported by kdesrc-build]].


=== Microsoft Windows ===
If you are a more seasoned developer you might be able to use Kubuntu for kdesrc-build by [[Get_Involved/development/More#Qt_6_installed_using_the_Qt_online_installer|installing Qt6 using the Qt online installer]] or by [[Get_Involved/development/More#Build_Qt_using_kdesrc-build|building Qt6 using kdesrc-build]].


You can build and develop KDE projects using the [[Get_Involved/development/Windows|Microsoft Windows]] operating system.
=== Alpine Linux ===


=== Apple macOS ===
<pre>
apk add git perl doas-sudo-shim
</pre>


You can build and develop KDE projects using the [[Get_Involved/development/Mac|Apple macOS]] operating system.
=== FreeBSD ===


== Advanced kdesrc-build ==
Install the latest release of FreeBSD with KDE Plasma Desktop on your hardware computer or in a virtual machine.


Note: these resources might not be up to date.
Your user should be member of the "wheel" user group (e.g. this can be configured in the FreeBSD installer, when creating your user you can select additional user groups for your user). Your user should be able to use sudo:


See the [https://docs.kde.org/trunk5/en/kdesrc-build/kdesrc-build/ kdesrc-build manual], [https://invent.kde.org/sdk/kdesrc-build/-/blob/master/README.md Readme #1], [https://invent.kde.org/sdk/kdesrc-build/-/blob/master/doc/README.md Readme #2], [https://invent.kde.org/sdk/kdesrc-build/-/blob/master/doc/source-reference/index.adoc Document #3] for more kdesrc-build information and options.
<pre>
pkg install sudo
visudo
# Uncomment the line: %wheel ALL=(ALL:ALL) ALL
</pre>


== Build Qt using kdesrc-build ==
Then set up kdesrc-build using the same procedure as when installing kdesrc-build on a Linux operating system. FreeBSD is currently supported by kdesrc-build. See https://www.youtube.com/watch?v=8MqBnb3Y9JU


Set up kdesrc-build from scratch as usual.
=== OpenBSD >= 7.5 ===


Open the configuration file <code>~/.config/kdesrc-buildrc</code> and confirm that <code>qtdir</code> and the lines <code>include...qt5-build-include</code> and <code>include...custom-qt5-libs-build-include</code> are not commented out (i.e. there should not be a <code>#</code> in front of the lines). E.g. (replace "username" with your Linux user's name):
Install OpenBSD version greater than or equal to 7.5. In the installer keep the defaults, the user created by the installer is named "administrator" in this example.
<pre>
# Enable doas
su -
cp /etc/examples/doas.conf /etc/doas.conf
exit
# kdesrc-build needs sudo.
mkdir -p ~/.local/bin ; ln -s /usr/bin/doas ~/.local/bin/sudo
echo "export PATH=~/.local/bin:\$PATH" >> ~/.bashrc


{{Input|1=<nowiki>
# Test doas.
qtdir ~/kde/usr # Where to make install Qt5
doas su
include /home/username/kde/src/kdesrc-build/qt5-build-include
# kde-builder needs bash.
include /home/username/kde/src/kdesrc-build/custom-qt5-libs-build-include
pkg_add bash
</nowiki>}}
chsh -s /usr/local/bin/bash
exit


Run in a terminal:
# As user administrator
chsh -s /usr/local/bin/bash


{{Input|1=<nowiki>
# As per https://rsadowski.de/posts/2024-01-09-openbsd-kde/ , https://openports.pl/path/meta/kde,-plasma
kdesrc-build Qt5
doas su
kdesrc-build frameworks
pkg_add kde-plasma kate
</nowiki>}}


== kdesrc-build, Qt6 and KDE Frameworks 6 ==
# I recommend that you use tigervnc. https://nmariusp.github.io/install-os.html#openbsd--75
</pre>


Set up kdesrc-build clean from scratch following the same procedure as when using "Qt5 and KDE Frameworks 5". Before building anything using kdesrc-build, do:
After you install kdesrc-build:
<pre>
# Edit the kdesrc-buildrc file e.g.:
cmake-options -DCMAKE_BUILD_TYPE=RelWithDebInfo -DKF_IGNORE_PLATFORM_CHECK=ON


{{Input|1=<nowiki>
# Also set environment variable:
sed -i 's/kf5-common/kf6-common/' ~/.config/kdesrc-buildrc
export CMAKE_PREFIX_PATH=/usr/local/lib/qt6/cmake
sed -i 's/kf5-qt5/kf6-qt6/' ~/.config/kdesrc-buildrc
# Or
</nowiki>}}
export CMAKE_PREFIX_PATH=/usr/local/lib/qt5/cmake
</pre>


The file <code>~/.config/kdesrc-buildrc</code> should contain the not commented out lines:
=== Microsoft Windows ===


{{Input|1=<nowiki>
You can build and develop KDE projects using the [[Get_Involved/development/Windows|Microsoft Windows]] operating system.
include /home/username/kde/src/kdesrc-build/kf6-common-options-build-include
...
include /home/username/kde/src/kdesrc-build/kf6-qt6-build-include
</nowiki>}}


In the file <code>~/.config/kdesrc-buildrc</code>, in the "global" section, the line "cmake-options" should contain "-DBUILD_WITH_QT6=ON".
=== Apple macOS ===


Then build KDE Frameworks 6:
You can build and develop KDE projects using the [[Get_Involved/development/Mac|Apple macOS]] operating system.


{{Input|1=<nowiki>
== What to do if CMake configure fails because a build dependency is missing ==
kdesrc-build frameworks
</nowiki>}}


Note: <code>kdesrc-build --initial-setup</code> does not install the packages needed for building with kdesrc-build "Qt6 and KDE Frameworks 6". The instructions on [[Guidelines and HOWTOs/Build from source/Install the dependencies|how to install the dependencies]] are for "Qt5 and KDE Frameworks 5" only, they do not work for "Qt6 and KDE Frameworks 6". Therefore many kdesrc-build modules will fail to build because of missing dependencies (CMake errors).
See https://community.kde.org/Get_Involved/development/Install_the_dependencies .


=== Install the dependencies ===
== Project Documentation ==


See below for some ideas about how to find out what Linux packages you need to install.
* [https://docs.kde.org/trunk5/en/kdesrc-build/kdesrc-build/ Handbook]
* [https://invent.kde.org/sdk/kdesrc-build/-/blob/master/README.md Readme #1]
* [https://invent.kde.org/sdk/kdesrc-build/-/blob/master/doc/README.md Readme #2]


E.g. I am on Kubuntu 22.10, <code>kdesrc-build frameworks</code> fails, module <code>kcoreaddons</code> has CMake (configure) error <code>Could NOT find Qt6LinguistTools (missing: Qt6LinguistTools_DIR)</code>.
Developer's documentation can be found in the {{ic|doc/source-reference}} in the project repo.


Option 1:
== kf6-qt6 vs. kf5-qt5 ==


Search on the internet for <code>ubuntu packages Qt6LinguistTools</code> it returns https://packages.ubuntu.com/kinetic/amd64/qt6-tools-dev Expand "amd64 [list of files]": <code>/usr/lib/x86_64-linux-gnu/cmake/Qt6LinguistTools/Qt6LinguistToolsConfig.cmake</code>
Many KDE git repositories can build correctly and run correctly using "kdesrc-build kf6-qt6".  


{{Input|1=<nowiki>
The KDE git repositories that can build correctly and run correctly using "kdesrc-build kf6-qt6" have two long lived git branches:
sudo apt install qt6-tools-dev
</nowiki>}}


Option 2:
* A long lived git branch that does not contain the deprecated symbols from kf5-qt5, named e.g. "master".
{{Input|1=<nowiki>
* And another long lived git branch for qt5-kf5, where the deprecated symbols still exist.
sudo apt install apt-file
sudo apt-file update
apt-file find Qt6LinguistToolsConfig.cmake
# qt6-tools-dev: /usr/lib/x86_64-linux-gnu/cmake/Qt6LinguistTools/Qt6LinguistToolsConfig.cmake
sudo apt install qt6-tools-dev
</nowiki>}}


If the error is:
What is "kf6-qt6"? You just set up kdesrc-build following the procedure. The resulting kdesrc-build installation will be of type kf6-qt6. In kdesrc-buildrc in the "global" section you will have "branch-group kf6-qt6". The git repositories that have only one long lived git branch e.g. named "master" will use that. The git repositories that have a second long lived git branch, will use the git branch where the deprecated symbols do not exist e.g. named "master".
{{Input|1=<nowiki>
The imported target "Qt6::qtwaylandscanner" references the file
    "/usr/lib/qt6/libexec/qtwaylandscanner"
but this file does not exist.
</nowiki>}}


Then:
What is "kf5-qt5"? Follow the chapter "kdesrc-build Qt5". The resulting kdesrc-build installation will be of type kf5-qt5. In kdesrc-buildrc in the "global" section you will have "branch-group kf5-qt5". The git repositories that have only one long lived git branch e.g. named "master" will use that. The git repositories that have a second long lived git branch where the deprecated symbols still exist e.g. named "kf5" will use that.
{{Input|1=<nowiki>
apt-file find /usr/lib/qt6/libexec/qtwaylandscanner
# qt6-wayland-dev-tools: /usr/lib/qt6/libexec/qtwaylandscanner
sudo apt install qt6-wayland-dev-tools
</nowiki>}}


Option 3:
== Build Qt using kdesrc-build ==
{{Input|1=<nowiki>
apt search linguist | grep qt6
# linguist-qt6/kinetic 6.3.1-2 amd64
sudo apt install linguist-qt6
</nowiki>}}


=== Ubuntu ===
=== Qt6 ===
If you cannot build the KDE frameworks using {{ic|kdesrc-build}} and the Qt provided by your Linux distribution is outdated, you might want to build the Qt framework using {{ic|kdesrc-build}}.


{{Input|1=<nowiki>
In your configuration file use the {{ic|qt-install-dir}} option (in the ''global'' section) with non-empty value, for example:
sudo apt install qt6-tools-dev qt6-declarative-dev libqt6core5compat6-dev qt6-wayland-dev qt6-wayland-dev-tools qt6-base-private-dev libqt6svg6-dev libqt6opengl6-dev libqt6shadertools6-dev
</nowiki>}}


== Build Qt6 using kdesrc-build ==
{{bc|
global
  qt-install-dir ~/kde/usr
  branch-group kf6-qt6
end global
}}


A screen recording version is available https://www.youtube.com/watch?v=TDzX0376QyA
It is recommended that if you build Qt6 using kdesrc-build, you also build qtwebengine. Edit the file {{ic|~/.local/state/sysadmin-repo-metadata/module-definitions/qt6.ksb}}. Follow the instructions found in the file: if you want qtwebengine, add it to use-modules after "qtwebchannel" and comment out the line "ignore-modules qtwebengine".


Note: If you cannot build the KDE frameworks using kdesrc-build and using the Qt6 provided by your OS (Linux distribution). Because the Qt6 is not complete. You might want to build Qt6 using kdesrc-build.
<pre>
kdesrc-build qtbase --refresh-build --debug
</pre>
Press Ctrl+C after the CMake configure summary for qtbase. Make sure that you have the needed dependencies. Should find libb2-dev, libproxy-dev, libmd4c-dev, libmd4c-html0-dev, libxcb-xinput-dev, libatspi2.0-dev, libsqlite3-dev, unixodbc-dev, libmysqlclient-dev, postgresql-client, libecpg-dev, libpq-dev. Optional dependencies libsctp-dev, libts-dev.


Note: Building Qt6 using kdesrc-build is an advanced topic.
<pre>
kdesrc-build qtwebengine
</pre>
This will build the Qt6 modules from qtbase up to qtwebengine. qtwebengine will probably be built incorrectly because some needed dependencies are missing.


Set up kdesrc-build clean from scratch following the same procedure as when using "Qt5 and KDE Frameworks 5".  
<pre>
kdesrc-build qtwebengine --refresh-build --debug
</pre>
Press Ctrl+C after the CMake configure summary for qtwebengine. Make sure that you have the needed dependencies. Should find node.js >= 14, libdbus-1-dev, libxcomposite-dev, libxshmfence-dev, libxdamage-dev, libharfbuzz-dev, libvpx-dev, libpci-dev, libevent-dev, libre2-dev, libsnappy-dev, libcups2-dev, libxkbfile-dev.


{{Input|1=<nowiki>
Then build Qt6: {{bc|kdesrc-build qt6-set}}
Edit two files:


cat ~/.config/kdesrc-buildrc
To compile Qt6 with Qt X11 Extras (which is a necessary library to compile [https://api.kde.org/frameworks/kwindowsystem/html/ KWindowSystem]), you should enable XCB feature during compilation
# This file controls options to apply when configuring/building modules, and
# controls which modules are built in the first place.
# List of all options: https://docs.kde.org/trunk5/en/kdesrc-build/kdesrc-build/conf-options-table.html


global
{{bc|1=kdesrc-build qt6-set --cmake-options="-DQT_FEATURE_xcb=ON"}}
    branch-group kf6-qt6


    # Finds and includes *KDE*-based dependencies into the build.  This makes
=== Qt5 ===
    # it easier to ensure that you have all the modules needed, but the
If you want the same for Qt5, change {{ic|branch-group}} option and use {{ic|qt5-set}} instead of {{ic|qt6-set}}.
    # dependencies are not very fine-grained so this can result in quite a few
    # modules being installed that you didn't need.
    include-dependencies true


    # Install directory for KDE software
== Qt 6 installed using the Qt online installer ==
    kdedir ~/kde/usr


    # Directory for downloaded source code
A screen recording version is available https://www.youtube.com/watch?v=3BIbYN2vIZw
    source-dir ~/kde/src


    # Directory to build KDE into before installing
The homepage of the Qt Framework is https://www.qt.io . Go to this web page, create an online account. https://www.qt.io/download-open-source > "Download the Qt Online Installer" > Linux > "Qt Online Installer for Linux (64-bit)" > download a file named e.g. qt-unified-linux-x64-4.6.1-online.run into the directory e.g. "~/Downloads".
    # relative to source-dir by default
    build-dir ~/kde/build


    qtdir  ~/kde/usr # Where to install Qt5 if kdesrc-build supplies it
<pre>
ls -la ~/Downloads # The downloaded file needs to have the "executable" chmod bit set.
chmod u+x ~/Downloads/qt-unified-linux-x64-4.6.1-online.run
~/Downloads/qt-unified-linux-x64-4.6.1-online.run
</pre>


    cmake-options -DCMAKE_BUILD_TYPE=Debug
A graphical user interface (GUI) installer wizard starts. Login using your Qt online account. Next > check the checkbox "I have read and agree to the terms and conditions of using OpenSource Qt", check the checkbox "I'm an individual and do not use Qt for any company" > Next > Next > enable "Help us improve" > Next > Custom installation, notice that the install directory is "~/Qt" > Next. Install the latest version of Qt6 and the latest version of the Qt Creator integrated development environment (IDE). There are some Qt6 components that are not used by KDE and can be left out when installing Qt6 e.g. Qt Design Studio, WebAssembly, Android, Sources, Qt Quick 3D, Qt 3D, Qt Quick 3D Physics, "Qt Debug Information Files". Next > enable "I have read and agree" > Next > Install.


    # kdesrc-build sets 2 options which is used in options like make-options or set-env
In the KDE Plasma app launcher (start menu) you now have the application "Qt Maintenance Tool".
    # to help manage the number of compile jobs that happen during a build:
    #
    # 1. num-cores, which is just the number of detected CPU cores, and can be passed
    #    to tools like make (needed for parallel build) or ninja (completely optional).
    #
    # 2. num-cores-low-mem, which is set to largest value that appears safe for
    #    particularly heavyweight modules based on total memory, intended for
    #    modules like qtwebengine
    num-cores 16
    num-cores-low-mem 12


    # kdesrc-build can install a sample .xsession file for "Custom"
Set up kdesrc-build from scratch as usual.
    # (or "XSession") logins,
    install-session-driver false


    # or add a environment variable-setting script to
Edit the file kdesrc-buildrc to look like:
    # ~/.config/kde-env-master.sh
    install-environment-driver true


    # Stop the build process on the first failure
<pre>
     stop-on-failure true
global
 
...
    # Use a flat folder layout under ~/kde/src and ~/kde/build
     qt-install-dir  ~/Qt/6.7.0/gcc_64 # Where to install Qt6 if kdesrc-build supplies it
    # rather than nested directories
     libname lib
    directory-layout flat
...
 
    # Build with LSP support for everything that supports it
     compile-commands-linking true
    compile-commands-export true
 
    git-repository-base qt6-copy https://invent.kde.org/qt/qt/
end global
end global
</pre>


# With base options set, the remainder of the file is used to define modules to build, in the
== Two independent kdesrc-build configurations: kf6-qt6 and kf5-qt5 ==
# desired order, and set any module-specific options.
#
# Modules may be grouped into sets, and this is the normal practice.
#
# You can include other files inline using the "include" command. We do this here
# to include files which are updated with kdesrc-build.


# Common options that should be set for some KDE modules no matter how
You can switch between configurations with {{ic|--rc-file}} command line option. Generate another config, make the changes for the {{ic|source-dir}}, {{ic|build-dir}}, {{ic|install-dir}},
# kdesrc-build finds them. Do not comment these out unless you know
and other changes you want. Make sure you use different value for {{ic|persistent-data-file}} option, to not mix things up.
# what you are doing.
include /home/username/kde/src/kdesrc-build/kf6-common-options-build-include


# Qt and some Qt-using middleware libraries. Uncomment if your distribution's Qt
As an alternative, you can utilize custom variable to make switch from a single config:
# tools are too old but be warned that Qt take a long time to build!
include /home/username/kde/src/kdesrc-build/qt6-build-include
include /home/username/kde/src/kdesrc-build/custom-qt6-libs-build-include


# KF5 and Plasma :)
{{bc-hl|shell|
#include /home/username/kde/src/kdesrc-build/kf6-qt6-build-include
global
 
    _ver 5  # <-- Change this to switch
# To change options for modules that have already been defined, use an
    source-dir ~/kde${_ver}/src
# 'options' block. See kf6-common-options-build-include for an example
    build-dir ~/kde${_ver}/build
    install-dir ~/kde${_ver}/usr
    persistent-data-file ~/kde${_ver}/persistent-options.json
end global


cat ~/kde/src/kdesrc-build/qt6-build-include  
include ~/.local/share/kdesrc-build/data/build-include/kf${_ver}-qt${_ver}.ksb
# Downloads and installs Qt6 from the KDE mirror, using Qt6's CMake support
}}
# exclusively.  Consider this an unofficial build that won't be supported by Qt
# upstream since we don't go through the init-repository script.
# It is probably better to install from your local distribution devel packages
# if possible!
module-set qt6-set
    override-build-system qt6 # technically optional for now


    repository qt6-copy # as defined in kdesrc-buildrc-kf6-sample
== Other CPU architectures than x86_64/amd64 and x86 ==
    branch    6.4


    # Controls where Qt6 is installed
You can build and develop KDE projects using a Linux OS installed on an  [[Get_Involved/development/ARM|ARM]] architecture CPU.
    prefix ${qtdir}


    # These have been manually placed in dependency order based on the
== kdesrc-build issues ==
    # .gitmodules file in https://code.qt.io/cgit/qt/qt5.git/tree/.gitmodules
    # in "essential" or "addons" categories with some additions
    # qtdoc should be last to give it best opportunity to make needed docs
    use-modules qtbase qtshadertools qtdeclarative qtsvg qttools \
        qtimageformats qtmultimedia qtwayland                    \
        qtwebsockets qtwebchannel qtwebengine qtwebview qtsensors            \
        qtnetworkauth qt5compat qtdoc


    # if you want qtwebengine, add it to use-modules after "qtwebchannel" and
See https://community.kde.org/Get_Involved/development/Install_the_dependencies
    # comment this out. Note qtwebengine has significant and different build
    # requirements of its own.
    #ignore-modules qtwebengine


    # Archiving API requires zstd support which may not be present in your CMake
=== "kdesrc-build kpat" fails because of black-hole-solitaire ===
    cmake-options -DQT_BUILD_TESTS=FALSE -DCMAKE_BUILD_TYPE=RelWithDebInfo \
                  -DQT_AVOID_CMAKE_ARCHIVING_API=TRUE


    cmake-generator Ninja # comment out if you want the default CMake generator
This happens on Debian/Ubuntu/Kubuntu. Because there is no Linux distribution binary package for https://github.com/shlomif/black-hole-solitaire.
end module-set


options qtwebengine
Solution: append at the end of kdesrc-buildrc file:
    # qtwebengine build system is weird, involving make as the top-level driver
<pre>
    # and then calling ninja for the bulk of the build.  qtwebengine is a bulky
options kpat
    # module and having ninja use all cores at once may run out of memory if
     cmake-options -DWITH_BH_SOLVER=OFF
    # not careful, so we use make to pass less aggressive Ninja flags.
    # num-cores-low-mem needs to be defined in your kdesrc-buildrc.
     make-options NINJAFLAGS=-j${num-cores-low-mem}
end options
end options
</pre>


# vim: set ft=kdesrc-buildrc:
=== libdisplay-info is not available ===


</nowiki>}}
If your Linux OS does not have a package for libdisplay-info.
Append at the end of the file <code>kdesrc-buildrc</code>:
<pre>
module libdisplay-info
  repository https://gitlab.freedesktop.org/emersion/libdisplay-info.git
end module
</pre>

Latest revision as of 05:04, 16 August 2024

This page is the continuation with more advanced topics of the page Get_Involved/development.

kde-builder is an alternative to kdesrc-build

kdesrc-build and kde-builder are two KDE build frameworks. They are used at the command line and have identical command line syntax, just replace the string "kdesrc-build" with "kde-builder". They use the same configuration file, named kdesrc-buildrc.

kde-builder is newer and regularly gets new features and is written in Python.

kdesrc-build is in maintenance mode and feature frozen and written in Perl.

The "how to install kde-builder" procedure is here https://invent.kde.org/sdk/kde-builder/-/blob/master/README.md .

Develop in a Linux container

When you start programming for KDE, it is recommended that you use kdesrc-build in your main operating system or in a virtual machine running on a Linux operating system that is better supported by kdesrc-build.

As an alternative, you can run kdesrc-build in a Linux container (docker, podman, toolbx, distrobox).

Option 1. The KDE PIM Docker image

You can install Docker and the KDE PIM Docker image. It provides a development environment that is isolated from your day-to-day system. It is based on KDE Neon Unstable.

Option 2. distrobox

It is possible to start developing KDE software using container images that are able to see inside your home folder. This can be done using distrobox and podman.

This solution is particularly useful for users on immutable distributions like Fedora Kinoite, openSUSE Kalpa or the Steam Deck's SteamOS.

To learn how to build KDE software with distrobox, see: https://develop.kde.org/docs/getting-started/building/containers-distrobox/

Other operating systems

Kubuntu >= 23.10

The default configuration of kdesrc-build requires Qt version 6.6. Kubuntu 23.10 and 24.04 have Qt version 6.4.2. It is recommended that you use a Linux OS that is better supported by kdesrc-build.

If you are a more seasoned developer you might be able to use Kubuntu for kdesrc-build by installing Qt6 using the Qt online installer or by building Qt6 using kdesrc-build.

Alpine Linux

apk add git perl doas-sudo-shim

FreeBSD

Install the latest release of FreeBSD with KDE Plasma Desktop on your hardware computer or in a virtual machine.

Your user should be member of the "wheel" user group (e.g. this can be configured in the FreeBSD installer, when creating your user you can select additional user groups for your user). Your user should be able to use sudo:

pkg install sudo
visudo
# Uncomment the line: %wheel ALL=(ALL:ALL) ALL

Then set up kdesrc-build using the same procedure as when installing kdesrc-build on a Linux operating system. FreeBSD is currently supported by kdesrc-build. See https://www.youtube.com/watch?v=8MqBnb3Y9JU

OpenBSD >= 7.5

Install OpenBSD version greater than or equal to 7.5. In the installer keep the defaults, the user created by the installer is named "administrator" in this example.

# Enable doas
su -
cp /etc/examples/doas.conf /etc/doas.conf
exit
# kdesrc-build needs sudo.
mkdir -p ~/.local/bin ; ln -s /usr/bin/doas ~/.local/bin/sudo
echo "export PATH=~/.local/bin:\$PATH" >> ~/.bashrc

# Test doas.
doas su
# kde-builder needs bash.
pkg_add bash
chsh -s /usr/local/bin/bash
exit

# As user administrator
chsh -s /usr/local/bin/bash

# As per https://rsadowski.de/posts/2024-01-09-openbsd-kde/ , https://openports.pl/path/meta/kde,-plasma
doas su
pkg_add kde-plasma kate

# I recommend that you use tigervnc. https://nmariusp.github.io/install-os.html#openbsd--75

After you install kdesrc-build:

# Edit the kdesrc-buildrc file e.g.:
cmake-options -DCMAKE_BUILD_TYPE=RelWithDebInfo -DKF_IGNORE_PLATFORM_CHECK=ON

# Also set environment variable:
export CMAKE_PREFIX_PATH=/usr/local/lib/qt6/cmake
# Or
export CMAKE_PREFIX_PATH=/usr/local/lib/qt5/cmake

Microsoft Windows

You can build and develop KDE projects using the Microsoft Windows operating system.

Apple macOS

You can build and develop KDE projects using the Apple macOS operating system.

What to do if CMake configure fails because a build dependency is missing

See https://community.kde.org/Get_Involved/development/Install_the_dependencies .

Project Documentation

Developer's documentation can be found in the doc/source-reference in the project repo.

kf6-qt6 vs. kf5-qt5

Many KDE git repositories can build correctly and run correctly using "kdesrc-build kf6-qt6".

The KDE git repositories that can build correctly and run correctly using "kdesrc-build kf6-qt6" have two long lived git branches:

  • A long lived git branch that does not contain the deprecated symbols from kf5-qt5, named e.g. "master".
  • And another long lived git branch for qt5-kf5, where the deprecated symbols still exist.

What is "kf6-qt6"? You just set up kdesrc-build following the procedure. The resulting kdesrc-build installation will be of type kf6-qt6. In kdesrc-buildrc in the "global" section you will have "branch-group kf6-qt6". The git repositories that have only one long lived git branch e.g. named "master" will use that. The git repositories that have a second long lived git branch, will use the git branch where the deprecated symbols do not exist e.g. named "master".

What is "kf5-qt5"? Follow the chapter "kdesrc-build Qt5". The resulting kdesrc-build installation will be of type kf5-qt5. In kdesrc-buildrc in the "global" section you will have "branch-group kf5-qt5". The git repositories that have only one long lived git branch e.g. named "master" will use that. The git repositories that have a second long lived git branch where the deprecated symbols still exist e.g. named "kf5" will use that.

Build Qt using kdesrc-build

Qt6

If you cannot build the KDE frameworks using kdesrc-build and the Qt provided by your Linux distribution is outdated, you might want to build the Qt framework using kdesrc-build.

In your configuration file use the qt-install-dir option (in the global section) with non-empty value, for example:

global
  qt-install-dir ~/kde/usr
  branch-group kf6-qt6
end global

It is recommended that if you build Qt6 using kdesrc-build, you also build qtwebengine. Edit the file ~/.local/state/sysadmin-repo-metadata/module-definitions/qt6.ksb. Follow the instructions found in the file: if you want qtwebengine, add it to use-modules after "qtwebchannel" and comment out the line "ignore-modules qtwebengine".

kdesrc-build qtbase --refresh-build --debug

Press Ctrl+C after the CMake configure summary for qtbase. Make sure that you have the needed dependencies. Should find libb2-dev, libproxy-dev, libmd4c-dev, libmd4c-html0-dev, libxcb-xinput-dev, libatspi2.0-dev, libsqlite3-dev, unixodbc-dev, libmysqlclient-dev, postgresql-client, libecpg-dev, libpq-dev. Optional dependencies libsctp-dev, libts-dev.

kdesrc-build qtwebengine

This will build the Qt6 modules from qtbase up to qtwebengine. qtwebengine will probably be built incorrectly because some needed dependencies are missing.

kdesrc-build qtwebengine --refresh-build --debug

Press Ctrl+C after the CMake configure summary for qtwebengine. Make sure that you have the needed dependencies. Should find node.js >= 14, libdbus-1-dev, libxcomposite-dev, libxshmfence-dev, libxdamage-dev, libharfbuzz-dev, libvpx-dev, libpci-dev, libevent-dev, libre2-dev, libsnappy-dev, libcups2-dev, libxkbfile-dev.

Then build Qt6:

kdesrc-build qt6-set

To compile Qt6 with Qt X11 Extras (which is a necessary library to compile KWindowSystem), you should enable XCB feature during compilation

kdesrc-build qt6-set --cmake-options="-DQT_FEATURE_xcb=ON"

Qt5

If you want the same for Qt5, change branch-group option and use qt5-set instead of qt6-set.

Qt 6 installed using the Qt online installer

A screen recording version is available https://www.youtube.com/watch?v=3BIbYN2vIZw

The homepage of the Qt Framework is https://www.qt.io . Go to this web page, create an online account. https://www.qt.io/download-open-source > "Download the Qt Online Installer" > Linux > "Qt Online Installer for Linux (64-bit)" > download a file named e.g. qt-unified-linux-x64-4.6.1-online.run into the directory e.g. "~/Downloads".

ls -la ~/Downloads # The downloaded file needs to have the "executable" chmod bit set.
chmod u+x ~/Downloads/qt-unified-linux-x64-4.6.1-online.run
~/Downloads/qt-unified-linux-x64-4.6.1-online.run

A graphical user interface (GUI) installer wizard starts. Login using your Qt online account. Next > check the checkbox "I have read and agree to the terms and conditions of using OpenSource Qt", check the checkbox "I'm an individual and do not use Qt for any company" > Next > Next > enable "Help us improve" > Next > Custom installation, notice that the install directory is "~/Qt" > Next. Install the latest version of Qt6 and the latest version of the Qt Creator integrated development environment (IDE). There are some Qt6 components that are not used by KDE and can be left out when installing Qt6 e.g. Qt Design Studio, WebAssembly, Android, Sources, Qt Quick 3D, Qt 3D, Qt Quick 3D Physics, "Qt Debug Information Files". Next > enable "I have read and agree" > Next > Install.

In the KDE Plasma app launcher (start menu) you now have the application "Qt Maintenance Tool".

Set up kdesrc-build from scratch as usual.

Edit the file kdesrc-buildrc to look like:

global
...
    qt-install-dir  ~/Qt/6.7.0/gcc_64 # Where to install Qt6 if kdesrc-build supplies it
    libname lib
...
end global

Two independent kdesrc-build configurations: kf6-qt6 and kf5-qt5

You can switch between configurations with --rc-file command line option. Generate another config, make the changes for the source-dir, build-dir, install-dir, and other changes you want. Make sure you use different value for persistent-data-file option, to not mix things up.

As an alternative, you can utilize custom variable to make switch from a single config:

global
    _ver 5  # <-- Change this to switch
    source-dir ~/kde${_ver}/src
    build-dir ~/kde${_ver}/build
    install-dir ~/kde${_ver}/usr
    persistent-data-file ~/kde${_ver}/persistent-options.json
end global

include ~/.local/share/kdesrc-build/data/build-include/kf${_ver}-qt${_ver}.ksb

Other CPU architectures than x86_64/amd64 and x86

You can build and develop KDE projects using a Linux OS installed on an ARM architecture CPU.

kdesrc-build issues

See https://community.kde.org/Get_Involved/development/Install_the_dependencies

"kdesrc-build kpat" fails because of black-hole-solitaire

This happens on Debian/Ubuntu/Kubuntu. Because there is no Linux distribution binary package for https://github.com/shlomif/black-hole-solitaire.

Solution: append at the end of kdesrc-buildrc file:

options kpat
    cmake-options -DWITH_BH_SOLVER=OFF
end options

libdisplay-info is not available

If your Linux OS does not have a package for libdisplay-info. Append at the end of the file kdesrc-buildrc:

module libdisplay-info
  repository https://gitlab.freedesktop.org/emersion/libdisplay-info.git
end module