Guidelines and HOWTOs/Build from source
Build KDE Frameworks and Applications
Install required devel packages
This section provides information about required and optional software packages needed to build the KDE applications.
Qt 5 (http://qt.io/) is the base of KDE software. Your distro provides suitable devel packages. Optionally, you can build your own Qt5: Frameworks/BuildingOwnQt5.
deb-based distributions (Debian, Kubuntu...)
$ sudo apt-get build-dep qtbase5-dev $ sudo apt-get install libbz2-dev libxslt-dev libxml2-dev shared-mime-info oxygen-icon-theme libgif-dev libvlc-dev libvlccore-dev doxygen gperf bzr libxapian-dev fontforge libgcrypt20-dev libattr1-dev network-manager-dev libgtk-3-dev xsltproc xserver-xorg-dev xserver-xorg-input-synaptics-dev libpwquality-dev modemmanager-dev libxcb-keysyms1-dev libepoxy-dev libpolkit-agent-1-dev libnm-util-dev libnm-glib-dev libegl1-mesa-dev libxcb-xkb-dev libqt5x11extras5-dev libwww-perl libxml-parser-perl libjson-perl libboost1.55-dev libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev libarchive-dev liblmdb-dev
openSUSE
openSUSE 13.2 (outdated)
All the necessary dependencies:
$ sudo zypper si -d libqt5-qtbase $ sudo zypper in libbz2-devel libxslt-devel libxml2-devel shared-mime-info oxygen-icon-theme giflib-devel vlc-devel doxygen gstreamer-0_10-devel gstreamer-0_10-plugins-base-devel docbook-xml-slides docbook-xsl-stylesheets xcb-util-keysyms-devel perl-JSON boost-devel libxcb-devel libXrender-devel xcb-util-wm-devel xcb-util-devel xcb-util-image-devel gettext-tools libepoxy-devel $ sudo zypper in gtk3-devel # for kde-gtk-config $ sudo zypper in grantlee5 # for kdevplatform $ sudo zypper in libkdcraw-devel liblcms2-devel # for gwenview
Optional for kdeplasma-addons: libibus >=1.4.2 (see http://software.opensuse.org/package/libibus-1_0-5)
openSUSE 42.1
Install these packages (including the recommended packages):
$ sudo zypper install git-core bzr ninja \ gettext-tools libqt5-qttools libgypsy0 libqt5-creator libqt5-linguist libqt5-qtbase-common-devel libqt5-qtbase-devel libqt5-qtbase-doc libqt5-qtbase-examples libqt5-qtdeclarative-devel libqt5-qtdeclarative-examples libqt5-qtdeclarative-tools libqt5-qtdoc libqt5-qtgraphicaleffects libqt5-qtimageformats libqt5-qtimageformats-devel libqt5-qtmultimedia-devel libqt5-qtmultimedia-examples libqt5-qtquick1-devel libqt5-qtquickcontrols libqt5-qtscript-devel libqt5-qtscript-examples libqt5-qtsvg-devel libqt5-qttools-devel libqt5-qtx11extras-devel libqt5-qtxmlpatterns-devel libqt5-qtxmlpatterns-examples libQt5CLucene5 libQt5Concurrent-devel libQt5Concurrent5 libQt5Core-devel libQt5Core5 libQt5DBus-devel libQt5DBus5 libQt5Declarative5 libQt5Designer5 libQt5DesignerComponents5 libQt5Gui-devel libQt5Gui5 libQt5Help5 libQt5Multimedia5 libQt5Network-devel libQt5Network5 libQt5OpenGL-devel libQt5OpenGL5 libQt5Positioning5 libQt5PrintSupport-devel libQt5PrintSupport5 libQt5Script5 libQt5Sensors5 libQt5Sql-devel libQt5Sql5 libQt5Sql5-mysql libQt5Sql5-postgresql libQt5Sql5-sqlite libQt5Sql5-unixODBC libQt5Svg5 libQt5Test-devel libQt5Test5 libQt5WebKit5 libQt5WebKitWidgets5 libQt5Widgets-devel libQt5Widgets5 libQt5X11Extras5 libQt5Xml-devel libQt5Xml5 libQt5XmlPatterns5 libQtQuick5 libQt5WebKitWidgets-devel libqt5-qtbase-private-headers-devel \ xcb-util-keysyms-devel docbook-xsl-stylesheets doxygen polkit-devel libepoxy-devel boost-devel libXcursor-devel libSM-devel giflib-devel libaccounts-qt5-devel gtk3-devel libpng16-devel fltk-devel libopenssl-devel libattr-devel ModemManager-devel NetworkManager-devel wayland-devel lmdb-devel xcb-proto-devel xcb-util-image-devel xcb-util-cursor-devel xcb-util-devel gtk2-devel libqca-qt5-devel libpwquality-devel libical-devel PackageKit-Qt5-devel pam-devel
- OPEN ISSUES:
- on my system 'ninja-1.6.0' was installed and when using 'custom-build-command ninja' in the kdesrc-buildrc below, the build of modules fails), maybe see https://bugs.kde.org/show_bug.cgi?id=331654
- Failing modules (of more than 200 modules)
- phonon-vlc, phonon-gstreamer, plasma-pa (PulseAudio missing), kdevplatform, plasma-desktop, kaccounts-integration, kaccounts-mobile, gwenview, kdevelop, libksane, skanlite, ...
Fedora
All the dependencies used for building frameworks can be installed by running:
$ sudo yum-builddep qt phonon-backend-vlc phonon-backend-gstreamer $ sudo yum install gcc-c++ ruby doxygen git bzr flex bison gperf socat boost-devel bzip2-devel libxslt-devel libxml2-devel shared-mime-info oxygen-icon-theme giflib-devel xcb-util-keysyms-devel perl-JSON perl-Pod-Usage "*xcb*-devel" perl-XML-Parser NetworkManager-glib-devel xapian-core-devel libxkbcommon-devel libxkbcommon-x11-devel systemd-devel libwayland-cursor-devel libwayland-server-devel libepoxy-devel gtk3-devel sane-backends-devel libattr-devel libcanberra-devel libusb-devel libxkbfile-devel fontforge-devel libical-devel gpgme-devel cyrus-sasl-devel openldap-devel libpwquality-devel polkit-devel lmdb-devel
Arch Linux
All the dependencies used for building frameworks can be installed by running:
$ sudo pacman -Sy --needed phonon-qt5 qt5-webkit qt5-script qt5-svg qt5-tools qt5-x11extras enchant jasper openexr libutempter docbook-xsl shared-mime-info giflib libxss upower udisks2 bzr git doxygen perl-json perl-libwww perl-xml-parser akonadi xorg-server-devel libpwquality fontforge eigen libfakekey qca-qt5 xapian-core xsd
Git remote prefix
Let's setup a "kde:" prefix for git commands. Add the following text to your ~/.gitconfig:
[url "git://anongit.kde.org/"]
insteadOf = kde:
[url "ssh://[email protected]/"]
pushInsteadOf = kde:
Clone kdesrc-build
First you need kdesrc-build, it can be done with the following commands:
mkdir -p extragear/utils git clone kde:kdesrc-build extragear/utils/kdesrc-build ln -s extragear/utils/kdesrc-build/kdesrc-build .
Download the configuration file
At this point,
- download http://www.davidfaure.fr/kde/kf5-qt5-kdesrc-buildrc into your source dir
- rename it to kdesrc-buildrc
You can use this command:
wget "http://www.davidfaure.fr/kde/kf5-qt5-kdesrc-buildrc" -O "kdesrc-buildrc"
Adjust the paths
Take a look at those lines in the configuration file you've downloaded:
# note that the qtdir line is not needed and can be commented out # when using distro installed Qt 5 packages # qtdir /d/qt/5/kde/qtbase source-dir /d/kde/src/5 build-dir /d/kde/build/5 kdedir /d/kde/inst/kde_frameworks
and adjust the paths the way you want.
- qtdir = Where Qt 5 is installed, or qtbase build dir if using uninstalled or comment out this line to use distro-installed Qt packages
- source-dir = where KDE Frameworks 5 sources should be downloaded, e.g. /home/dev/dev/kde/src
- build-dir = where KDE Frameworks 5 should be built, e.g. /home/dev/kde/build
- kdedir = your KDE Frameworks 5 installation directory, e.g. /home/dev/kde/usr
NOTE, that it is not possible to use variables like $HOME (and probably not recommended to use the tilde for home: ~).
Note: Append -std=c++11 to the cxxflags in the kdesrc-buildrc. Otherwise, you'll be no able to build libdbusmenu-qt.
Run kdesrc-build
You just have to run ./kdesrc-build
to build the KDE Frameworks.
It is the preferred way of building KDE Frameworks.
If you want you can also do the work by hand following the detailed instructions: /Details.
Example for openSUSE 13.1 with pre-built Qt 5 packages installed via zypper:
# directory structure looks like this now: # src/ # extragear/ # utils/ # kde-srcbuild/ # kdesrc-build [symlink to extragear/utils/kde-srcbuild/kdesrc-build] # $ cd <your kf5 src dir where kdesrc-build symlink is located> $ export CMAKE_PREFIX_PATH=/usr/lib64/cmake/Qt5 $ ./kdesrc-build
NOTE 2016-01-18 / openSUSE 42.1, that the build seems to work without the "export CMAKE_PREFIX_PATH=/usr/lib64/cmake/Qt5"
Analyse and fix build errors
If kdesrc-build shows you red module names with messages like "Unable to configure plasma-mediacenter with CMake!" or "Unable to build kdepim!", you have to start troubleshooting:
- The latest build log is written to
src/log/latest/<module-name>/
- In case of error there will be an error.log file with useful information. You will often see that there is only a build dependency missing.
Runtime setup
To use your new KF5 install prefix (let's call it $KF5) :
export KF5=<path to your intended frameworks install directory>
export QTDIR=<path to your qt5 install dir, or qtbase build dir if using uninstalled>
export XDG_DATA_DIRS=$KF5/share:$XDG_DATA_DIRS:/usr/share
export XDG_CONFIG_DIRS=$KF5/etc/xdg:$XDG_CONFIG_DIRS:/etc/xdg
export PATH=$KF5/bin:$QTDIR/bin:$PATH
export QT_PLUGIN_PATH=$KF5/lib/plugins:$KF5/lib64/plugins:$KF5/lib/x86_64-linux-gnu/plugins\
:$QTDIR/plugins:$QT_PLUGIN_PATH
# (lib64 instead of lib, on OpenSUSE and similar)
export QML2_IMPORT_PATH=$KF5/lib/qml:$KF5/lib64/qml:$KF5/lib/x86_64-linux-gnu/qml:$QTDIR/qml
export QML_IMPORT_PATH=$QML2_IMPORT_PATH
export KDE_SESSION_VERSION=5
export KDE_FULL_SESSION=true
Note that LD_LIBRARY_PATH isn't set. You shouldn't set it, the builtin rpath works magic instead, and if you set it you'll have issues when running tools that use uninstalled libs while building frameworks (e.g. meinproc, kconfig_compiler...)
For what works on Debian Sid alongside with packaged KF5 nicely see: Using (parts of) self-built KF 5, Plasma 5 and/or KDE Applications on Debian (note I do set LD_LIBRARY_PATH there and it still uses any libraries from system that are not available self-built, it may depend on whether you want to build all of KF5/Plasma or just parts of it and whether you want the system wide parts to use your newly compiled stuff)
To use separate user settings for KF5:
export XDG_DATA_HOME=$HOME/.local5/share
export XDG_CONFIG_HOME=$HOME/.config5
export XDG_CACHE_HOME=$HOME/.cache5
To be able to compile other stuff on top of KF5:
export CMAKE_PREFIX_PATH=$KF5:$CMAKE_PREFIX_PATH
To get more information out of qDebug statements (i.e. make it more like kDebug) :
export QT_MESSAGE_PATTERN='%{appname}(%{pid})/%{category} %{function}: %{message}'
or even better, to get colors:
c=`echo -e "\033"`
export QT_MESSAGE_PATTERN="%{appname}(%{pid})/(%{category}) ${c}[31m%{if-debug}${c}[34m%{endif}\
%{function}${c}[0m: %{message}"
unset c
To set a KDE5 default editor (for git and svn)
export EDITOR="kwrapper5 kwrite"
Don't bother with KDEDIR and KDEHOME etc. this stuff isn't used anymore.
$ which ksnapshot
should show you now the location of the built version, not the one in the system path /usr/bin/ if you setup the paths correctly.
To run an application, e.g. ksnapshot, you need a separate DBus session because the dbus server needs to have the right value of XDG_DATA_DIRS, in order to find $KF5/share/dbus-1/services for starting services (e.g. kded5). (Only needed when working under KDE4?). Kded5 is not needed for every feature but everytime when kioexec (which is used by KRun) is involved.
$ eval `dbus-launch` # no console output expected, (kdeinit5 is started automatically when needed) $ ksnapshot
Running unit tests
Unit tests are ran from the build dir of each framework, you should first cd into it.
You need a separate DBus session because the dbus server needs to have the right value of XDG_DATA_DIRS, in order to find $KF5/share/dbus-1/services for starting services (e.g. kded5).
eval `dbus-launch` kdeinit5 make test
Note: Regular apps will start kdeinit5 automatically. The reason it has to be started by hand when running unittests is some strange interaction with ctest.
Warning: never start a KDE 4 application in this separate DBus session, it would conflict with your running Plasma 4 desktop. Note: KDE_FULL_SESSION=true is needed to make sure that the correct QPA will be loaded.
Many of the tests require an X server, and will pop up windows briefly. An easy way to allow these tests to run without interfering with your normal X session is to do
xvfb-run -s '-screen 0 1024x768x24' make test
(the -s argument tells Xvfb to set the first screen to be 1024x768 pixels, with a depth of 24; at least one test requires a depth greater than 8). In this case, if you also ensure DBUS_SESSION_BUS_ADDRESS is not set, the tests should not find your existing D-Bus session, and instead launch a new D-Bus instance.
Note that the KWindowSystem tests require a NETWM-compatible window manager to be running. One way to do this is to create a script to run such a window manager, followed by whatever is passed to it. For example, if you have the window manager awesome installed, you could create a script called awesome-run as follows:
#!/bin/sh
awesome &
exec "$@"
and then run the tests as
xvfb-run -s '-screen 0 1024x768x24' /path/to/awesome-run make test
If you want to publish your test results, instead of "make test" run
make Experimental
The test results will appear on http://my.cdash.org/index.php?project=<projectname>
Troubleshooting
Compilation: how to quickly solve build problems
Situation:
One or more modules fail to build via kdesrcbuild (displayed in red font).
Steps to solve (in the given order):
1) Check KDE build server if the module is maybe currently broken: http://build.kde.org/view/FAILED/
For the next two steps we assume your kf5 development directory structure looks like this:
kf5 `- build `- src `- usr
2) Delete usr and run kdesrcbuild again.
3) see Analyse and fix build errors
4) Delete build and usr. Run kdesrcbuild again.
5a) Ask on IRC or mailing list (see Communicating with the team)
5b) Check if there are changes in the build instructions: see History of this wiki page.
6) Start over from scratch.
Runtime: generic runtime problem
Try to delete ~/.cache5, ~/.config5, ~/.local5
(WARN: make sure not accidently delete your own config, the directories without the 5)
Runtime: Segfault when a sound is about to play (e.g. for a message box)
(added: 2015-02-27)
Example of the problem: open kate, edit some file without saving, Ctrl+W to close, a message box is about to appear and the then segfault:
kate(9037)/default KNotificationManager::notify: Calling notify on "Sound" Segmentation fault
This command can solve the problem:
sudo /usr/lib64/vlc/vlc-cache-gen -f /usr/lib64/vlc/plugins
See also:
Alternative: go to kf5/build/kdesupport/phonon/phonon-vlc/ and exec `make uninstall`
Runtime: kded5 crashes because of some component
(added: 2015-Jan)
Situation: kded5 is started but crashes because of some dependency. Stacktraces show for example `bluedevil` as possible cause.
Goal 1: disable the component to verify it as crash cause.
Steps:
1) locate bluedevil files using `locate bluedevil`, for example.
2) Among the files there is `dev/kf5/usr/share/kservices5/kded/bluedevil.desktop`. Remove it. If it was the cause, kded should stop crashing
Goal 2: Remove bluedevil from kdesrcbuild until it gets fixed.
Steps:
1) Search through the dev/kf5/src/extragear/utils/kdesrc-build/*-build-include files to find the component. In this case, it was found in kf5-workspace-build-include.
2) Comment it out:
# module-set kf5-bluetooth-management # repository kde-projects # use-modules libbluedevil bluedevil # end module-set
Further calls of `kdesrcbild` will not include the component.
Runtime: Couldn't start kded5 (KDE4)
(added: 2014-Dec)
Situation: developing and executing KF5 apps under KDE 4.
Problem by example: error message on console when starting ksnapshot in KF5 environment
ksnapshot(26577)/default KSycocaPrivate::checkDatabase: Couldn't start kded5 from org.kde.kded5.service: QDBusError("org.freedesktop.DBus.Error.ServiceUnknown", "The name org.kde.kded5 was not provided by any .service files") , falling back to running kbuildsycoca5
Solution (not verified yet): as said in the article, run this command before starting the app itself:
. setup-kf5-env # (or as your script is called) eval `dbus-launch` # no output expected ksnapshot # no kded5 error message expected
Runtime: Icon theme was changed (KDE4)
(added: 2014-Oct, verified: 2015-Feb)
Situation: developing and executing KF5 apps under KDE 4.
Problem: After working a bit with KF5 applications your regular KDE icon theme might be changed from oxygen to breeze.
Solution: see https://forum.kde.org/viewtopic.php?f=67&t=25032: Open "Icons - KDE Control Module" and change the theme back to Oxygen.
Get more help
If you still have trouble with the building process or runtime setup you can contact people as described in Communicating with the team.
More specifically, here is a list of beginner people who have recently had built the project and would like to specifically help with build problems. Feel free to add them to the recipient list when writing to the mailing list:
Alternative building methods
Kubuntu CI
Kubuntu CI (replaces Project Neon 5) provides packages of KDE Git master for KDE Frameworks and Plasma 5. Install them on your Kubuntu system to work with KDE Git.
Docker
Build with docker: Frameworks/BuildingAlternatives