Jump to content

Get Involved/development/More: Difference between revisions

From KDE Community Wiki
Ashark (talk | contribs)
Two independent kdesrc-build configurations */ Clarify instructions to switch between configs
Nmariusp (talk | contribs)
Develop in a Linux container: KDE PIM docker uses a too old docker image from 2022
 
(52 intermediate revisions by 4 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]].


== kdesrc-build Qt5 ==
kde-builder has replaced the previous KDE build framework named kdesrc-build.


kdesrc-build by default uses Qt6. Your kdesrc-build installation is configured for Qt6 if in the configuration file <code>kdesrc-buildrc</code> you have <code>branch-group kf6-qt6</code>.
== Develop in a Linux container ==


You can convert your kdesrc-build installation from Qt6 to Qt5 by editing the existing kdesrc-buildrc file to replace all occurrences of "6" with "5".
When you start programming for KDE, it is recommended that you [[Get_Involved/development|use kde-builder 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 kde-builder]].


Set up kdesrc-build following the "Set up kdesrc-build" 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".
As an alternative, you can run kde-builder in a Linux container (docker, podman, toolbx, distrobox).


Edit the file <code>~/.config/kdesrc-buildrc</code>
=== distrobox ===
* Replace all "6" with "5".


Example:
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.


{{bc-hl|1=bash|2=
This solution is particularly useful for users on immutable distributions like Fedora Kinoite, openSUSE Kalpa or Valve's SteamOS 3
# Make sure that you do not already have a kdesrc-build
# installation that uses the configuration file
# ~/.config/kdesrc-buildrc


# Make a backup:
To learn how to build KDE software with distrobox, see: https://develop.kde.org/docs/getting-started/building/containers-distrobox/
mv ~/.config/kdesrc-buildrc ~/.config/kdesrc-buildrc~bak 2> /dev/null
mv ~/kde5 ~/kde5~bak 2> /dev/null


mkdir -p ~/kde5/src
== Other operating systems ==
cd ~/kde5/src
git clone https://invent.kde.org/sdk/kdesrc-build.git && cd kdesrc-build
./kdesrc-build --initial-setup <<< 'N'
mv ~/.config/kdesrc-buildrc .
 
# Edit the file ~/kde5/src/kdesrc-build/kdesrc-buildrc:
# A. Replace "/home/username/kde5/src/kdesrc-build/" with "".
sed -i 's_/home/.*/src/kdesrc-build/__g' kdesrc-buildrc
 
# B. Replace "~/kde/" with "~/kde5/".
sed -i 's_~/kde/_~/kde5/_g' kdesrc-buildrc
 
# C. Replace "num-cores 4" with the count of your CPU threads (nproc) minus two. E.g. if you have 16 CPU threads, use "num-cores 14".
 
# D. If you plan to use the C++ debugger, replace "-DCMAKE_BUILD_TYPE=RelWithDebInfo" with "-DCMAKE_BUILD_TYPE=Debug".
 
# E. Replace "6" with "5".
sed -i 's/6/5/g' kdesrc-buildrc
 
# Make sure that the configuration file
# ~/kde5/src/kdesrc-build/kdesrc-buildrc looks OK
# E.g. kate ~/kde5/src/kdesrc-build/kdesrc-buildrc &


# From now on you will need to be in the directory
=== Kubuntu >= 24.10 ===
# ~/kde5/src/kdesrc-build before you can run kdesrc-build or kdesrc-run


# E.g.
The default configuration of kde-builder requires Qt version 6.7. Kubuntu 24.10 has Qt version 6.6. It is recommended that you use a [[Get_Involved/development#Operating_system|Linux OS that is better supported by kde-builder]].
cd ~/kde5/src/kdesrc-build
./kdesrc-build kconfig
./kdesrc-build kcalc
./kdesrc-run kcalc
./kdesrc-build frameworks
}}


== kde-builder ==
If you are a more seasoned developer you might be able to use Kubuntu for kde-builder by [https://develop.kde.org/docs/getting-started/building/kde-builder-setup/#qt6-online installing Qt6 using the Qt online installer] or by [https://develop.kde.org/docs/getting-started/building/kde-builder-setup/#qt6-build building Qt6 using kde-builder].


kde-builder is a drop in replacement of kdesrc-build. kdesrc-build is written in Perl. kde-builder is written in Python.
=== Alpine Linux ===


<pre>
<pre>
mkdir -p ~/Development
apk add git perl doas-sudo-shim
cd ~/Development
git clone https://invent.kde.org/ashark/kde-builder.git
cd kde-builder
python3 -m venv .venv
# I use bash.
source .venv/bin/activate
pip install pipenv
pipenv install
./kde-builder --initial-setup <<< 'N'
mv ~/.config/kdesrc-buildrc .
sed -i 's_~/kde/_~/Development/_g' kdesrc-buildrc
# Edit the file ./kdesrc-buildrc as needed.
kate kdesrc-buildrc &
# meld kdesrc-buildrc ~/kde/src/kdesrc-build/kdesrc-buildrc
 
# kde-builder is installed.
# Use ./kde-builder instead of ./kdesrc-build. The command lines are the same.
# Use ./kde-builder-launch instead of ./kdesrc-run. The command lines are the same.
 
./kde-builder kconfig
./kde-builder kcalc
./kde-builder-launch kcalc
./kde-builder frameworks
</pre>
</pre>
== 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.
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|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.
First, install distrobox and podman from your distribution repositories:
* Debian/Ubuntu: sudo apt install distrobox podman
* openSUSE: sudo zypper install distrobox podman
* Fedora: sudo dnf install distrobox podman
* Arch: sudo pacman --sync distrobox podman
==== Building without kdesrc-build ====
You can build a single repository using the [https://community.kde.org/Neon/Containers KDE Neon Unstable docker image]. We will be using the <code>plasma:unstable</code> image, which comes with the latest KDE software and libraries, and we will be using the minimal version, which requires you to install development libraries before compiling your projects.
After installing distrobox and podman, run the following to create a new distrobox container:
{{Input|
podman pull invent-registry.kde.org/neon/docker-images/plasma:unstable
distrobox create --image invent-registry.kde.org/neon/docker-images/plasma:unstable
}}
This will create a distrobox container named '''plasma-unstable'''.
{{Note|The plasma:unstable image size is 5.6 GB.}}
Lastly, enter the generated container:
{{Input|
distrobox enter plasma-unstable
}}
You can then just clone the desired repository in your home folder and build it while being inside the container. If any development libraries are missing, you can just install them the same way you would install on Debian/Ubuntu/KDE Neon:
{{Input|
sudo apt install packagename-dev
}}
You can also use <code>build-dep</code> to let apt install the required libraries for the program you will be compiling. For example, to install the development libraries for Kate, you can run:
{{Input|
sudo apt-get build-dep kate
}}
==== Building with kdesrc-build ====
First, install distrobox and podman from your distribution repositories. Then run:
{{Input|
distrobox enter
}}
This should create a container based on your current Linux OS and enter it. It is preferable to use one of the Linux distributions that is better suited for kdesrc-build, as mentioned [[Get_Involved/development#Operating_system|in this wiki page]], so if your distribution does not provide very up-to-date packages, you can download and use a different container image for your distrobox from [https://hub.docker.com/search?type=image Dockerhub]. For example, with openSUSE Tumbleweed:
{{Input|
podman pull opensuse/tumbleweed
distrobox create --image opensuse/tumbleweed --name tumbleweed
distrobox enter tumbleweed
}}
Then it's a matter of downloading and running kdesrc-build as detailed in [[Get_Involved/development/Set_up_a_development_environment]]:
<syntaxhighlight lang="bash">
mkdir -p ~/kde/src
cd ~/kde/src
git clone https://invent.kde.org/sdk/kdesrc-build.git
cd kdesrc-build
./kdesrc-build --initial-setup
source ~/.bashrc
</syntaxhighlight>
From this point on, one important thing to bear in mind is that a distrobox container is transparent in its user space and containerized in its root space: when you are inside a distrobox container, you can see the content of system's home folder, but not your system's root folders, only the container's root folders. This means that you can install packages inside the container using root privileges and access those packages to compile your programs stored in your home, without ever installing those packages in your actual system!
You can take advantage of this by installing, for instance, Qt development packages used for kdesrc-build from inside the container. This way, it is not necessary to compile Qt with kdesrc-build. This is particularly convenient if you want to compile KDE software with Qt6 quickly.
Likewise, you should [https://community.kde.org/Get_Involved/development/Install_the_dependencies install the required dependencies] from inside the distrobox rather than from your system's repositories. Then you can start compiling as usual.
After compiling your program with kdesrc-build from inside the distrobox, you can run it with <code>kdesrc-build run</code>, and despite it originating from inside a container and using the libraries from the container, it will run just fine as a GUI application on your system!
The only few gotchas to using this method are:
* You cannot use a [[Get_Involved/development/Build_software_with_kdesrc-build#Plasma|full Plasma Desktop session]] made from git.
* You will need qqc2-desktop-style and Breeze to show the correct theme for your applications.
* You will need the QtWayland library and its respective development package to run your applications natively on a Wayland session.
== Other operating systems ==
=== Kubuntu 23.10 ===
The default configuration of kdesrc-build requires Qt version 6.6. Kubuntu 23.10 has Qt version 6.4.2. It is recommended that you [[Get_Involved/development/More#Build_Qt6_using_kdesrc-build|build Qt in Kubuntu]] or use a [[Get_Involved/development#Operating_system|Linux OS that is better supported by kdesrc-build]].


=== FreeBSD ===
=== FreeBSD ===
Line 202: Line 43:
</pre>
</pre>


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
Then set up kde-builder using the same procedure as when installing kde-builder on a Linux operating system. FreeBSD is currently supported by kde-builder. See https://www.youtube.com/watch?v=AhDHUg81M_I and https://www.youtube.com/watch?v=HRiKzaw8cAw .


=== Microsoft Windows ===
=== OpenBSD >= 7.5 ===


You can build and develop KDE projects using the [[Get_Involved/development/Windows|Microsoft Windows]] operating system.
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>
=== Apple macOS ===
# Enable doas
su -
cp /etc/examples/doas.conf /etc/doas.conf
exit
# kde-builder needs sudo.
mkdir -p ~/.local/bin ; ln -s /usr/bin/doas ~/.local/bin/sudo
echo "export PATH=~/.local/bin:\$PATH" >> ~/.bashrc


You can build and develop KDE projects using the [[Get_Involved/development/Mac|Apple macOS]] operating system.
# Test doas.
doas su
# kde-builder needs bash.
pkg_add bash
chsh -s /usr/local/bin/bash
exit


== What to do if CMake configure fails because a build dependency is missing ==
# As user administrator
chsh -s /usr/local/bin/bash


See https://community.kde.org/Get_Involved/development/Install_the_dependencies .
# 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


== Advanced kdesrc-build ==
# I recommend that you use tigervnc. https://nmariusp.github.io/install-os.html#openbsd--75
 
After you have edited a git repository and you want to build it, <code>--no-src</code> will make sure that <code>kdesrc-build</code> does not overwrite your local source code changes with the latest source code from the official git repository (remote "origin" / https://invent/kde.org).
 
<code>--no-include-dependencies</code> only builds the git repository that you give as parameter to <code>kdesrc-build</code>.
 
<code>--debug</code> shows verbose output.
 
<code>--refresh-build</code> forces a rebuild (not an incremental build) and a full reinstall.
 
E.g. you have edited kcalc. You run:
<pre>
kdesrc-build kcalc --no-src --no-include-dependencies --refresh-build --debug |& tee ~/a.txt
</pre>
</pre>


For details, see:
After you install kde-builder:
<pre>
<pre>
kdesrc-build --help
# Edit the kdesrc-buildrc file e.g.:
</pre>
cmake-options -DCMAKE_BUILD_TYPE=RelWithDebInfo -DKF_IGNORE_PLATFORM_CHECK=ON
 
Note: the resources below might not be up to date.
 
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.
 
== Qt 6 installed using Qt online installer ==
 
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".


<pre>
# Also set environment variable:
ls -la ~/Downloads # The downloaded file needs to have the "executable" chmod bit set.
export CMAKE_PREFIX_PATH=/usr/local/lib/qt6/cmake
chmod +x ~/Downloads/qt-unified-linux-x64-4.6.1-online.run
# Or
~/Downloads/qt-unified-linux-x64-4.6.1-online.run
export CMAKE_PREFIX_PATH=/usr/local/lib/qt5/cmake
</pre>
</pre>


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. WebAssembly, Android, Sources, "Qt Quick 3D", "Qt 3D", "Quick: 3D Physics", "Qt debug Information Files".
=== Microsoft Windows ===


In the KDE Plasma app launcher you now have the application "Qt Maintenance Tool".
You can build and develop KDE projects using the [[Get_Involved/development/Windows|Microsoft Windows]] operating system.


Set up kdesrc-build from scratch as usual.
=== Apple macOS ===


Edit the file kdesrc-buildrc to look like:
You can build and develop KDE projects using the [[Get_Involved/development/Mac|Apple macOS]] operating system.
 
<pre>
global
...
    qt-install-dir ~/Qt/6.6.0/gcc_64 # Where Qt6 is installed
    libname lib
...
end global
...
</pre>


Make gpgme build:
== Project Documentation ==


<pre>
* https://kde-builder.kde.org
sudo su
* https://invent.kde.org/sdk/kde-builder
mkdir -p /home/qt/work
chown -R username:username /home/qt/work
ln -s /home/username/Qt/6.6.0/gcc_64 /home/qt/work/install
ls -la /home/qt/work
</pre>


== kf6-qt6 vs. kf5-qt5 ==
== kf6-qt6 vs. kf5-qt5 ==


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


The KDE git repositories that can build correctly and run correctly using "kdesrc-build kf6-qt6" have two long lived git branches:
The KDE git repositories that can build correctly and run correctly using "kde-builder 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".
* 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.
* 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 "kf6-qt6"? You just set up kde-builder following the procedure. The resulting kde-builder installation will be of type kf6-qt6. In kde-builder.yaml 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 Qt6 using kdesrc-build ==
 
If you cannot build the KDE frameworks using {{ic|kdesrc-build}} and the Qt6 provided by your Linux distribution is outdated, you might want to build Qt6 using {{ic|kdesrc-build}}.
 
In your configuration file use the {{ic|qt-install-dir}} option (in the ''global'' section) with non-empty value, for example:
 
{{bc|
global
  qt-install-dir ~/kde6/usr_qt
end global
}}
 
Then build it: {{bc|kdesrc-build qt6-set}}


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
What is "kf5-qt5"? Follow the chapter "kde-builder Qt5". The resulting kde-builder installation will be of type kf5-qt5. In kde-builder.yaml 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.


{{bc|1=kdesrc-build qt6-set --cmake-options="-DQT_FEATURE_xcb=ON"}}
== Two independent kde-builder configurations: kf6-qt6 and kf5-qt5 ==
 
After that, you can build other modules.
 
== Two independent kdesrc-build configurations: kf6-qt6 and kf5-qt5 ==


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}},
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}},
Line 330: Line 130:
}}
}}


== What is the command line of the processes started by kdesrc-build ==
== Other CPU architectures than x86_64/amd64 ==
 
E.g. what are the command lines that are run by kdesrc-build in order to run the CMake configure step for the kconfig KDE git repository?
 
<syntaxhighlight lang="bash">
kdesrc-build kconfig --no-src --no-include-dependencies --debug --refresh-build |& tee ~/a.txt
kate ~/a.txt &
</syntaxhighlight>
 
Returns:
 
<syntaxhighlight lang="bash">
Building kconfig (build system KDE CMake) from frameworks (1/1)
Queueing PKG_CONFIG_PATH to be set to /home/username/kde/usr/lib/pkgconfig
Queueing LD_LIBRARY_PATH to be set to /home/username/kde/usr/lib
Queueing PATH to be set to /home/username/kde/usr/bin:/home/username/kde/src/kdesrc-build:/home/username/.local/bin:/home/username/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
Not prepending /home/username/kde/usr/lib/pkgconfig to PKG_CONFIG_PATH as it appears to already be defined in PKG_CONFIG_PATH.
Queueing PKG_CONFIG_PATH to be set to /home/username/kde/usr/lib/pkgconfig
Not prepending /home/username/kde/usr/lib to LD_LIBRARY_PATH as it appears to already be defined in LD_LIBRARY_PATH.
Queueing LD_LIBRARY_PATH to be set to /home/username/kde/usr/lib
Not prepending /home/username/kde/usr/bin to PATH as it appears to already be defined in PATH.
Queueing PATH to be set to /home/username/kde/usr/bin:/home/username/kde/src/kdesrc-build:/home/username/.local/bin:/home/username/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
Queueing CMAKE_PREFIX_PATH to be set to /home/username/kde/usr
Queueing CMAKE_MODULE_PATH to be set to /home/username/kde/usr/lib64/cmake:/home/username/kde/usr/lib/cmake
Queueing XDG_DATA_DIRS to be set to /home/username/kde/usr/share:/usr/share/plasma:/home/username/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share:/var/lib/snapd/desktop
Source update complete for kconfig: Skipped
cd /home/username/kde/build
 
Preparing build system for kconfig.
Removing files in build directory for kconfig
Old build system cleaned, starting new build system.
cd /home/username/kde/build/kconfig
 
Running cmake targeting Unix Makefiles...
run_logged_p(): Module kconfig, Command: {'cmake', '-B', '.', '-S', '/home/username/kde/src/kconfig', '-G', 'Unix Makefiles', '-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON', '-DCMAKE_BUILD_TYPE=Debug', '-DQT_MAJOR_VERSION=6', '-DBUILD_WITH_QT6=ON', '-DBUILD_TESTING=TRUE', '-DBUILD_WITH_QT6=ON', '-DCMAKE_CXX_FLAGS:STRING=-pipe', '-DCMAKE_INSTALL_PREFIX=/home/username/kde/usr'} from /home/username/kde/build/kconfig
cd /home/username/kde/build/kconfig
 
log_command(): Module kconfig, Command: cmake -B . -S /home/username/kde/src/kconfig -G Unix Makefiles -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON -DCMAKE_BUILD_TYPE=Debug -DQT_MAJOR_VERSION=6 -DBUILD_WITH_QT6=ON -DBUILD_TESTING=TRUE -DBUILD_WITH_QT6=ON -DCMAKE_CXX_FLAGS:STRING=-pipe -DCMAKE_INSTALL_PREFIX=/home/username/kde/usr
run_logged_p(): kconfig cmake complete: 0
</syntaxhighlight>
 
Therefore, kdesrc-build has run the following commands:
 
<syntaxhighlight lang="bash">
# Preparing build system for kconfig. Removing files in build directory for kconfig. Old build system cleaned, starting new build system.
rm -rf /home/username/kde/build/kconfig
mkdir -p /home/username/kde/build/kconfig
 
# Queueing X to be set to ...
PKG_CONFIG_PATH=/home/username/kde/usr/lib/pkgconfig
LD_LIBRARY_PATH=/home/username/kde/usr/lib
PATH=/home/username/kde/usr/bin:/home/username/kde/src/kdesrc-build:/home/username/.local/bin:/home/username/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
CMAKE_PREFIX_PATH=/home/username/kde/usr
CMAKE_MODULE_PATH=/home/username/kde/usr/lib64/cmake:/home/username/kde/usr/lib/cmake
XDG_DATA_DIRS=/home/username/kde/usr/share:/usr/share/plasma:/home/username/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share:/var/lib/snapd/desktop
 
cd /home/username/kde/build/kconfig
 
cmake -B . -S /home/username/kde/src/kconfig -G Unix\ Makefiles -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON -DCMAKE_BUILD_TYPE=Debug -DQT_MAJOR_VERSION=6 -DBUILD_WITH_QT6=ON -DBUILD_TESTING=TRUE -DBUILD_WITH_QT6=ON -DCMAKE_CXX_FLAGS:STRING=-pipe -DCMAKE_INSTALL_PREFIX=/home/username/kde/usr
</syntaxhighlight>


== How to write the entire verbose STDOUT and STDERR of kdesrc-build to a file ==
You can build and develop KDE projects using a Linux OS installed on an [[Get_Involved/development/ARM|ARM]] architecture CPU.


<pre>
== kde-builder issues ==
script -eq -c "kdesrc-build kconfig --no-src --no-include-dependencies --refresh-build --debug" ~/a.txt ;  sed -i $'s/\033\[[0-9]\+m//g' ~/a.txt
</pre>


The <code>sed</code> part removes the terminal ANSI color escape codes.
=== "kde-builder kpat" fails because of black-hole-solitaire ===
 
<code>script -eq -c "command" ~/a.txt</code> is better than <code>command |& tee ~/a.txt</code> because kdesrc-build behaves differently if it is run in a user interactive terminal session (<code>isatty</code>).
 
If using <code>tee</code>, part of the output of kdesrc-build will not be written to file. E.g. the output of the <code>cmake</code> step, the final part of the <code>make -j</code> step, the final part of the <code>make install</code> step.
 
== Other CPU architectures than x86_64/amd64 and x86 ==
 
You can build and develop KDE projects using a Linux OS installed on an  [[Get_Involved/development/ARM|ARM]] architecture CPU.
 
== kdesrc-build issues ==
 
See https://community.kde.org/Get_Involved/development/Install_the_dependencies
 
=== wayland-protocols is too old, e.g. "kdesrc-build kidletime" fails ===
 
<pre>
mkdir -p ~/kde/misc && cd ~/kde/misc
wget https://gitlab.freedesktop.org/wayland/wayland-protocols/-/releases/1.31/downloads/wayland-protocols-1.31.tar.xz
tar -xJvf wayland-protocols-*.tar.xz && mv wayland-protocols-*/ wayland-protocols
cd wayland-protocols
meson setup builddir --prefix $HOME/kde/usr
meson compile -C builddir
meson install -C builddir
</pre>
 
=== "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.
This happens on Debian/Ubuntu/Kubuntu. Because there is no Linux distribution binary package for https://github.com/shlomif/black-hole-solitaire.
Line 432: Line 145:
     cmake-options -DWITH_BH_SOLVER=OFF
     cmake-options -DWITH_BH_SOLVER=OFF
end options
end options
</pre>
=== libdisplay-info is not available ===
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>
</pre>

Latest revision as of 23:17, 22 December 2024

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

kde-builder has replaced the previous KDE build framework named kdesrc-build.

Develop in a Linux container

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

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

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 Valve's SteamOS 3

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

Other operating systems

Kubuntu >= 24.10

The default configuration of kde-builder requires Qt version 6.7. Kubuntu 24.10 has Qt version 6.6. It is recommended that you use a Linux OS that is better supported by kde-builder.

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

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 kde-builder using the same procedure as when installing kde-builder on a Linux operating system. FreeBSD is currently supported by kde-builder. See https://www.youtube.com/watch?v=AhDHUg81M_I and https://www.youtube.com/watch?v=HRiKzaw8cAw .

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
# kde-builder 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 kde-builder:

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

Project Documentation

kf6-qt6 vs. kf5-qt5

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

The KDE git repositories that can build correctly and run correctly using "kde-builder 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 kde-builder following the procedure. The resulting kde-builder installation will be of type kf6-qt6. In kde-builder.yaml 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 "kde-builder Qt5". The resulting kde-builder installation will be of type kf5-qt5. In kde-builder.yaml 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.

Two independent kde-builder 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

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

kde-builder issues

"kde-builder 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