Get Involved/development/More: Difference between revisions
(→Build Qt5 using kdesrc-build: It is very difficult to build Qt5 using kdesrc-build) |
(→Qt6: qtbase depends on these DEB files) |
||
(76 intermediate revisions by 7 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]]. | ||
== 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 | 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 === | ||
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 | |||
On systems which are designed for you to not tamper with their root files (immutable distributions like openSUSE Kalpa, Fedora Kinoite, and SteamOS on the Steam Deck) you can use an [https://distrobox.it/#alternative-methods official alternative method] to install distrobox: | |||
{{Input|<nowiki> | |||
curl -s https://raw.githubusercontent.com/89luca89/distrobox/main/install | sh -s -- --prefix ~/.local | |||
</nowiki>}} | |||
On the Steam Deck, you will additionally need to add <tt>~/.local/bin</tt> to the <code>$PATH</code>. | |||
==== 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: | First, install distrobox and podman from your distribution repositories. Then run: | ||
Line 31: | Line 89: | ||
}} | }} | ||
Then it's a matter of downloading and running kdesrc-build as detailed in [ | Then it's a matter of downloading and running kdesrc-build as detailed in [https://develop.kde.org/docs/getting-started/building/kdesrc-build-setup/ Set up a development environment]: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
mkdir -p ~/ | mkdir -p ~/.local/share/ | ||
cd ~/ | cd ~/.local/share | ||
git clone https://invent.kde.org/sdk/kdesrc-build.git | git clone https://invent.kde.org/sdk/kdesrc-build.git | ||
cd kdesrc-build | |||
./kdesrc-build --initial-setup | ./kdesrc-build --initial-setup | ||
mkdir -p ~/.local/bin | |||
ln -sf ~/.local/share/kdesrc-build/kdesrc-build ~/.local/bin | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 48: | Line 108: | ||
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! | 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! | ||
{{Note|If you are on an X11 session, you will need to create the file <tt>~/.config/distrobox/distrobox.conf</tt> and add <code>xhost +si:localuser:$USER</code> to it in order for distrobox to be able to run graphical applications.}} | |||
The only few gotchas to using this method are: | The only few gotchas to using this method are: | ||
* You cannot use a [ | * You cannot use a [https://develop.kde.org/docs/getting-started/building/kdesrc-build-compile/#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 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. | * You will need the QtWayland library and its respective development package to run your applications natively on a Wayland session. | ||
== Other operating systems == | == 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 use a [[Get_Involved/development#Operating_system|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 [[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]]. | |||
=== FreeBSD === | === FreeBSD === | ||
Line 69: | Line 137: | ||
</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= | 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. | |||
<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 | |||
# 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 | |||
</pre> | |||
After you install kdesrc-build: | |||
<pre> | |||
# 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 | |||
</pre> | |||
=== Microsoft Windows === | |||
You can build and develop KDE projects using the [[Get_Involved/development/Windows|Microsoft Windows]] operating system. | |||
=== Apple macOS === | |||
You can build and develop KDE projects using the [[Get_Involved/development/Mac|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 == | |||
* [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] | |||
Developer's documentation can be found in the {{ic|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 {{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}}. | |||
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 ~/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 {{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". | |||
< | <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. | |||
<pre> | <pre> | ||
kdesrc-build | kdesrc-build qtwebengine | ||
</pre> | </pre> | ||
This will build the Qt6 modules from qtbase up to qtwebengine. qtwebengine will probably be built incorrectly because some needed dependencies are missing. | |||
<pre> | <pre> | ||
kdesrc-build -- | kdesrc-build qtwebengine --refresh-build --debug | ||
</pre> | </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. | |||
Then build Qt6: {{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 | |||
{{bc|1=kdesrc-build qt6-set --cmake-options="-DQT_FEATURE_xcb=ON"}} | |||
== Qt 6 installed using Qt online installer == | === Qt5 === | ||
If you want the same for Qt5, change {{ic|branch-group}} option and use {{ic|qt5-set}} instead of {{ic|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". | 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> | <pre> | ||
ls -la ~/Downloads # The downloaded file needs to | ls -la ~/Downloads # The downloaded file needs to have the "executable" chmod bit set. | ||
chmod +x ~/Downloads/qt-unified-linux-x64-4.6.1-online.run | chmod u+x ~/Downloads/qt-unified-linux-x64-4.6.1-online.run | ||
~/Downloads/qt-unified-linux-x64-4.6.1-online.run | ~/Downloads/qt-unified-linux-x64-4.6.1-online.run | ||
</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, | 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 you now have the application "Qt Maintenance Tool". | In the KDE Plasma app launcher (start menu) you now have the application "Qt Maintenance Tool". | ||
Set up kdesrc-build from scratch as usual. | Set up kdesrc-build from scratch as usual. | ||
Line 215: | Line 274: | ||
<pre> | <pre> | ||
global | global | ||
... | ... | ||
qt-install-dir ~/Qt/6.7.0/gcc_64 # Where to install Qt6 if kdesrc-build supplies it | |||
libname lib | libname lib | ||
... | ... | ||
end global | end global | ||
</pre> | </pre> | ||
== | == 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}}, | |||
and other changes you want. Make sure you use different value for {{ic|persistent-data-file}} option, to not mix things up. | |||
As an alternative, you can utilize custom variable to make switch from a single config: | |||
{{bc-hl|shell| | |||
global | 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 | |||
source-dir ~/ | |||
build-dir ~/ | |||
end global | end global | ||
include ~/.local/share/kdesrc-build/data/build-include/kf${_ver}-qt${_ver}.ksb | |||
}} | |||
== Other CPU architectures than x86_64/amd64 and x86 == | == Other CPU architectures than x86_64/amd64 and x86 == | ||
Line 649: | Line 306: | ||
== kdesrc-build issues == | == 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 === | === wayland-protocols is too old, e.g. "kdesrc-build kidletime" fails === | ||
Line 681: | Line 331: | ||
</pre> | </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> | |||
== More == | |||
=== How to write the entire verbose STDOUT and STDERR of kdesrc-build to a file === | |||
<pre> | <pre> | ||
kdesrc-build | script -eq -c "kdesrc-build kconfig --no-src --no-include-dependencies --refresh-build --debug" ~/a.txt | ||
</pre> | </pre> | ||
Note: you can remove the terminal ANSI color codes using e.g. ansi2txt, available e.g. in the package colorized-logs. E.g. | |||
<pre> | <pre> | ||
sudo apt install colorized-logs | |||
cat ~/a.txt | ansi2txt > ~/a_script.txt | |||
</pre> | </pre> | ||
<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 an interactive terminal session (isatty(3)). | |||
If using tee, part of the output of kdesrc-build will not be written to file. E.g. the output of the cmake step, the final part of the <code>make -j</code> step, the final part of the <code>make install</code> step. |
Revision as of 20:30, 21 May 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.
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
On systems which are designed for you to not tamper with their root files (immutable distributions like openSUSE Kalpa, Fedora Kinoite, and SteamOS on the Steam Deck) you can use an official alternative method to install distrobox:
curl -s https://raw.githubusercontent.com/89luca89/distrobox/main/install | sh -s -- --prefix ~/.local
On the Steam Deck, you will additionally need to add ~/.local/bin to the $PATH
.
Building without kdesrc-build
You can build a single repository using the KDE Neon Unstable docker image. We will be using the plasma:unstable
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:
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.
Lastly, enter the generated container:
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:
sudo apt install packagename-dev
You can also use build-dep
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:
sudo apt-get build-dep kate
Building with kdesrc-build
First, install distrobox and podman from your distribution repositories. Then run:
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 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 Dockerhub. For example, with openSUSE Tumbleweed:
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 Set up a development environment:
mkdir -p ~/.local/share/
cd ~/.local/share
git clone https://invent.kde.org/sdk/kdesrc-build.git
cd kdesrc-build
./kdesrc-build --initial-setup
mkdir -p ~/.local/bin
ln -sf ~/.local/share/kdesrc-build/kdesrc-build ~/.local/bin
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 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 kdesrc-build run
, 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 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 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.
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
wayland-protocols is too old, e.g. "kdesrc-build kidletime" fails
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
"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
More
How to write the entire verbose STDOUT and STDERR of kdesrc-build to a file
script -eq -c "kdesrc-build kconfig --no-src --no-include-dependencies --refresh-build --debug" ~/a.txt
Note: you can remove the terminal ANSI color codes using e.g. ansi2txt, available e.g. in the package colorized-logs. E.g.
sudo apt install colorized-logs cat ~/a.txt | ansi2txt > ~/a_script.txt
script -eq -c "command" ~/a.txt
is better than command |& tee ~/a.txt
because kdesrc-build behaves differently if it is run in an interactive terminal session (isatty(3)).
If using tee, part of the output of kdesrc-build will not be written to file. E.g. the output of the cmake step, the final part of the make -j
step, the final part of the make install
step.