Jump to content

Krita/kf5build: Difference between revisions

From KDE Community Wiki
Halla (talk | contribs)
Created page with "This page provides information about how to build and install Krita 3 from source using the kdesrc-build tool. This installation of Krita will be separate from any existing pl..."
 
Halla (talk | contribs)
No edit summary
Line 1: Line 1:
This page provides information about how to build and install Krita 3 from source using the kdesrc-build tool. This installation of Krita will be separate from any existing plasma installation, so that either of them can be run as desired.
= Build requirements =
This section provides information about '''hard''' (required) and '''optional''' software packages needed to build Qt5, Kf5 and Krita3.


= Preparation =
=== Dependencies ===
== Git remote prefix ==
 
Let's setup a "kde:" prefix for git commands. Add the following text to your ~/.gitconfig:
These are the deps for Qt5 and Kf5: the extra dependencies for Krita also need to be installed (but you probably have them already)
<syntaxhighlight lang="ini">
 
[url "git://anongit.kde.org/"]
*'''deb-based distributions (Debian, Kubuntu...):'''
  insteadOf = kde:
<pre  style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: normal;">$ sudo apt-get build-dep qtbase5-dev
[url "ssh://git@git.kde.org/"]
$ 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 libegl-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
  pushInsteadOf = kde:
</pre>
 
*'''openSUSE:''' All the necessary dependencies:
<pre  style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: normal;">$ 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
</pre>
Optional for kdeplasma-addons: libibus >=1.4.2 (see http://software.opensuse.org/package/libibus-1_0-5)
*'''Fedora:''' All the dependencies used for building frameworks can be installed by running:
<pre  style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: normal;">
$ 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
</pre>
*'''Arch Linux:''' All the dependencies used for building frameworks can be installed by running:
<pre  style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: normal;">
$ 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
</pre>
$ <your_AUR_helper> kf5-akonadi-git
 
=== Qt 5 ===
Qt 5 (http://qt.io/) is the base of KDE software. Choose one of the following sections to get your Qt setup. If you build Qt with the intention to actually develop Qt patches then you should go for a full debug build. If you merely need Qt to develop KDE applications then you should go for the release with debug symbol version.
 
{{Note|<b>ArchLinux users</b>: qtwebkit and qtwebengine use Python to generate some files, but they use Python 2.x syntax. So you have to make ''python'' pointing to ''/usr/bin/python2'', to do that see the [https://wiki.archlinux.org/index.php/Python#Python_2 Arch Wiki].}}
 
==== Qt5 full debug build ====
* PRO: full control and debugging capabilities
* CON: takes long to compile on the first time, might be an additional source of errors for beginners
 
To build all of qt5 execute:
<syntaxhighlight lang="bash">
git clone git://code.qt.io/qt/qt5.git --branch 5.4
cd qt5
./init-repository
./configure -prefix $PWD/qtbase -opensource -confirm-license -nomake tests -nomake examples \
  -dbus -no-separate-debug-info -xcb -system-xcb -qpa xcb -no-gtkstyle -developer-build
make
</syntaxhighlight>
 
To update qt5 later:
<syntaxhighlight lang="bash">
git pull
git submodule sync
git submodule update --recursive
</syntaxhighlight>
</syntaxhighlight>


==Create directories for build and installation==
If you saw changes (i.e. qt5.git got updated since last time),
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
sudo mkdir -p ~/kf5/{sources,build,install,logs}
./configure [...same as above...]
sudo chown -R $USER:$GROUP ~/kf5
make
mkdir -p ~/.kde5/{local,config,cache}   # Optional, only if you want separate directory for config files in your home
echo $?   # you should make extra sure that 'make' didn't abort with an error, especially when using -j
</syntaxhighlight>
</syntaxhighlight>


== Clone kdesrc-build ==
Experimental and not officially supported: if you don't have enough time and disk space for all of qt5, you could restrict yourself to separate checkouts of qtbase.git, qtsvg.git, qtx11extras.git, qtscript.git and qttools.git, this is enough to build  frameworks/* (but not enough for plasma-framework).
First you need kdesrc-build:
 
==== Qt5 release with debug symbols build ====
* PRO: This build is the most ideal build when developing applications and tuning performance. It has the speed of a release build but with debug symbols which give you more information in for example kcachegrind with data collected through valgrind.
* CON: The Qt libraries will be quite a lot bigger due to the debug symbols.
 
To build all of qt5 execute:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
cd ~/kf5/sources
git clone git://code.qt.io/qt/qt5.git --branch 5.4
git clone kde:kdesrc-build
cd qt5
cd kdesrc-build
./init-repository
./configure -prefix $PWD/qtbase -opensource -confirm-license -nomake tests -nomake examples -dbus \
  -no-separate-debug-info -xcb -system-xcb -qpa xcb -no-gtkstyle -release -force-debug-info -reduce-relocations \
  -optimized-qmake
make
</syntaxhighlight>
</syntaxhighlight>
The rest of the commands will be run from inside this directory.


== kdesrc-build configuration==
==== Use packages from your distribution ====
Save the following as <code>~/.kdesrc-buildrc</code>.
* PRO: faster to get started, one source of errors less
<pre>
* CON: usually doesn't have debug symbols. Great for developing applications and measuring performance. Not so great for tuning performance (you'd need debug symbols for that).
global
 
Note that the Qt version currently must be '''>= 5.4'''
 
1) openSUSE:
* 13.2: add the repository http://download.opensuse.org/repositories/KDE:/Qt54/openSUSE_13.2/
* install packages:
<pre  style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: normal;">
$ sudo zypper install libqt5-qttools libgypsy0 libqt5-creator libqt5-linguist libqt5-qtbase-common-devel libqt5-qtbase-debugsource libqt5-qtbase-devel libqt5-qtbase-doc libqt5-qtbase-examples libqt5-qtdeclarative-debugsource libqt5-qtdeclarative-devel libqt5-qtdeclarative-examples libqt5-qtdeclarative-tools libqt5-qtdoc libqt5-qtgraphicaleffects libqt5-qtimageformats libqt5-qtimageformats-debugsource 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-debugsource 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
</pre>
(these might be too much packages but with those the KF5 build worked)
 
2) Debian
* For now, Qt >= 5.4 can only be found in experimental repository. If it's not already the case, add it to your sources list and update : 
<pre  style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: normal;">
$ echo 'deb http://ftp.debian.org/debian experimental main' >> /etc/apt/sources.list
$ sudo apt-get update
 
$ sudo apt-get install -t experimental qtbase5-dev qtbase5-private-dev libqt5x11extras5-dev qtscript5-dev qttools5-dev libqt5svg5-dev libqt5xmlpatterns5-dev qttools5-dev-tools qtdeclarative5-dev
</pre>
 
3) Other distributions: yet to be documented.


    #qtdir /path/to/custom/qt          # Uncomment if you have your own qt build
=== Alternative: compile KF5 into Docker ===
    source-dir  ~/kf5/sources
You can use Docker to keep your main system clean and avoid to install a lot of packages.
    build-dir  ~/kf5/build
    kdedir  ~/kf5/install
    log-dir  ~/kf5/logs


    git-repository-base    kde-projects kde:
Follow the instructions given at the follow repository: https://github.com/Mathux/docker-kdesrc-build
    branch-group            kf5-qt5


    cmake-options -DCMAKE_BUILD_TYPE:STRING=debug
Hints for openSUSE to get started:


    cxxflags -pipe -DQT_STRICT_ITERATORS -DQURL_NO_CAST_FROM_STRING -DQT_NO_HTTP -DQT_NO_FTP -Wformat -Werror=format-security -Werror=return-type -Wno-variadic-macros -Wlogical-op -Wmissing-include-dirs
1) '''install'''
sudo zypper install docker


    # If you want to use ninja instead of make (it's faster!), add -GNinja to cmake-options above
2) If the error message
    # and uncomment the next line
<pre  style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: normal;">
    #custom-build-command ninja
FATA[0000] Post http:///var/run/docker.sock/v1.16/images/create?fromImage=busybox%3Alatest: dial unix /var/run/docker.sock: no such file or directory
</pre>
appears whenever trying to execute any docker command then you have to start:
sudo systemctl '''start docker'''


    # Adjust to the number of  CPU cores
3) Add your user to the '''docker group'''
    #make-options -j2


    ignore-kde-structure    true        # Downloads all modules directly into the source folder instead of subdirectories
4) Proceed as described in the github project.
    stop-on-failure        true        # Stop kdesrc-build when a build fails.


end global
5) Beware of '''low disk space''' on your root partition (see http://blog.eye48.com/post/98551740424/when-docker-io-eats-up-your-disc-space)


include ~/kf5/sources/kdesrc-build/kf5-frameworks-build-include
= Build KDE Frameworks and its dependencies =
include ~/kf5/sources/kdesrc-build/kf5-workspace-build-include
{{Note|For instructions on building and running Plasma 5, see [[Plasma/Building]].}}
== Git remote prefix ==
Let's setup a "kde:" prefix for git commands. Add the following text to your ~/.gitconfig:
<syntaxhighlight lang="ini">
[url "git://anongit.kde.org/"]
  insteadOf = kde:
[url "ssh://[email protected]/"]
  pushInsteadOf = kde:
</syntaxhighlight>


#Uncomment the next two lines to build application and PIM modules
== Clone kdesrc-build ==
#include ~/kf5/sources/kdesrc-build/kf5-applications-build-include
First you need kdesrc-build, it can be done with the following commands:
#include ~/kf5/sources/kdesrc-build/kf5-kdepim-build-include
<pre>
mkdir -p extragear/utils
git clone kde:kdesrc-build extragear/utils/kdesrc-build
ln -s extragear/utils/kdesrc-build/kdesrc-build .
</pre>
</pre>


* Adjust the paths to wherever you want to build and install Krita 3
== Download the configuration file ==
* Adjust the value of 'make-options -j4'. It is usually recommended to set to the number of CPU cores.
At this point,
* Uncomment the last two lines if you also want to build the Applications and PIM suite.
# download http://www.davidfaure.fr/kde/kf5-qt5-kdesrc-buildrc into your source dir
# rename it to '''kdesrc-buildrc'''
You can use this command:
<pre>
wget "http://www.davidfaure.fr/kde/kf5-qt5-kdesrc-buildrc" -O "kdesrc-buildrc"
</pre>
== Adjust the paths ==
Take a look at those lines in the configuration file you've downloaded:
<pre>
  # 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
</pre>
and adjust the paths the way you want.
* qtdir = Where Qt 5 is installed, or qtbase build dir if using uninstalled
* source-dir = where KDE Frameworks 5 sources should be downloaded
* build-dir = where KDE Frameworks 5 should be built
* kdedir = your KDE Frameworks 5 installation directory
 
Note: Append '''-std=c++11''' to the '''cxxflags''' in the '''kdesrc-buildrc'''. Otherwise, you'll be no able to build libdbusmenu-qt.
{{Note|The value of <tt>'''''kde-dir'''''/share</tt> must be included in the environment variable <tt>'''XDG_DATA_DIRS'''</tt> or otherwise the build will fail. kdesrc-build should handle this for you.}}
{{Note|The Qt dir must be included in the environment variable <tt>'''CMAKE_PREFIX_PATH'''</tt> otherwise kdesrc-build will fail to configure most modules.}}


Explore other available options in the [https://kdesrc-build.kde.org/documentation/conf-options-table.html official documentation]
== Run kdesrc-build ==
{{Note|Note that this script uses GIT and Bazaar to download the sources, so ensure you have both installed. }}
{{Note|Ensure that C++ compiler is g++. Building KDE with clang has linking errors.}}
You just have to run <code>./kdesrc-build</code> to build the KDE Frameworks.
It is the preferred way of building KDE Frameworks.  


=Building=
{{Note|kdesrc-build will only pick up the kdesrc-buildrc file you downloaded and edited above if it is in the same directory you run kdesrc-build from. If you save it to ~/.kdesrc-buildrc, however, it will be used no matter where you run kdesrc-build from. }}
==Dependencies==
Krita 3 will need various dependencies to be installed. You can find a list of dependencies for atleast the frameworks [https://community.kde.org/Frameworks/Building#Dependencies here]. Any other dependencies can be figured out and installed as you continue building the modules one by one.


At the very minimum, <code>qt5</code>, <code>cmake</code>, <code>g++</code>, <code>git</code>, <code>bzr</code>, <code>libwww-perl</code>, <code>libjson-perl</code> and <code>libxml-parser-perl</code>  needs to be installed to get started.
If you want you can also do the work by hand following the detailed instructions: [[Frameworks/Building/Details]].


===Kubuntu===
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


{{warning| Building Krita using these instructions does not work on Kubuntu due to the way they have incorrectly set up Qt.
=== Analyse and fix build errors ===
Please use any non Debian based distro}}


For Kubuntu 15.04, here's a list of packages that should satisfy all the dependencies of the default kdesrc-build projects, including Frameworks, Applications and Krita Workspace but excluding kdegames. Just copy-paste this to your terminal: <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: normal;">sudo apt-get install libxslt1-dev libpolkit-agent-1-dev libpolkit-gobject-1-dev libpolkit-backend-1-dev debhelper dh-apparmor icu-devtools libboost1.55-dev libcln-dev libglib2.0-dev libgmp-dev libgmpxx4ldbl libgps-dev libicu-dev libqalculate-dev libqimageblitz-dev libqt5sensors5 libqt5sensors5-dev libqt5webkit5-dev libqt5x11extras5-dev libraw1394-dev libudev-dev libusb-dev libxapian-dev libxcb-composite0-dev libxcb-cursor-dev libxcb-cursor0 libxcb-damage0-dev libxcb-dpms0 libxcb-dpms0-dev libxcb-ewmh-dev libxcb-ewmh2 libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-record0-dev libxcb-render-util0-dev libxcb-res0 libxcb-res0-dev libxcb-screensaver0 libxcb-screensaver0-dev libxcb-shm0-dev libxcb-util0-dev libxcb-xevie0 libxcb-xevie0-dev libxcb-xf86dri0 libxcb-xf86dri0-dev libxcb-xinerama0 libxcb-xinerama0-dev libxcb-xkb-dev libxcb-xprint0 libxcb-xprint0-dev libxcb-xtest0-dev libxcb-xv0 libxcb-xv0-dev libxcb-xvmc0 libxcb-xvmc0-dev libxml2-dev pkg-kde-tools po-debconf qttools5-dev xcb-proto xvfb qtscript5-dev qtdeclarative5-dev qtbase5-dev qtbase5-dev-tools qt5-qmake doxygen bzr libjson-perl perl-modules cmake cmake-data libapr1 libaprutil1 libserf-1-1 libsvn1 libxml-parser-perl subversion git build-essential libqt5svg5-dev libgpgme11-dev libgcrypt20-dev libepoxy-dev  libssl-dev libjpeg-dev libjpeg-turbo8-dev libjpeg8-dev libgif-dev qtbase5-private-dev qtxmlpatterns5-dev-tools libqt5xmlpatterns5-dev libqt5xmlpatterns5-private-dev libvlc-dev libvlccore-dev gir1.2-gst-plugins-base-1.0 gir1.2-gstreamer-1.0 libasound2-dev libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev libnm-util-dev libnm-glib-dev libattr1-dev qtquick1-5-dev libgrantlee5-dev liblcms2-dev libexiv2-dev libarchive-dev libcups2-dev libfakekey-dev libpam-dev libxrender-dev libpng-dev libxcursor-dev liblmdb-dev libsm-dev</pre>
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 <pre>src/log/latest/<module-name>/</pre>
* 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.


===Arch===
== Use Kubuntu CI ==
For Arch, here's a list of packages that should satisfy all the dependencies of the default kdesrc-build projects, including Frameworks, Applications and Krita Workspace but excluding kdegames. Just copy-paste this to your terminal: <pre  style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: normal;">
[https://community.kde.org/Kubuntu/PPAs#Kubuntu_Continuous_Integration_.28CI.29 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.
sudo pacman -S base-devel bzr cmake perl-libwww perl-xml-parser perl-json git qt5-tools docbook-xml docbook-xsl python2 boost modemmanager networkmanager vlc xapian-core xorg-server-devel
</pre>


==kdesrc-build commands==
= Runtime setup =
Run kdesrc-build as:
To use your new KF5 install prefix (let's call it $KF5) :
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
./kdesrc-build --debug
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
</syntaxhighlight>
</syntaxhighlight>
By default, kdesrc-build sends all output to log files. --debug will print build and install progress in the terminal too.


Sometimes a build will fail, and if <code>stop-on-failure true</code> is present in the options (as above), kdesrc-build will stop here. After the reason for the build failure has been analysed and fixed, you can resume building from that module by:
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...)
 
To use separate user settings for KF5:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
./kdesrc-build --debug --resume-from=<name>
export XDG_DATA_HOME=$HOME/.local5/share
export XDG_CONFIG_HOME=$HOME/.config5
export XDG_CACHE_HOME=$HOME/.cache5
</syntaxhighlight>
</syntaxhighlight>


If that application build cannot be fixed at present, you can skip building it by:
To be able to compile other stuff on top of KF5:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
./kdesrc-build --debug --resume-after=<name>
export CMAKE_PREFIX_PATH=$KF5:$CMAKE_PREFIX_PATH
</syntaxhighlight>
</syntaxhighlight>


A single module can be build using:
To get more information out of qDebug statements (i.e. make it more like kDebug) :
<syntaxhighlight lang="bash">
export QT_MESSAGE_PATTERN='%{appname}(%{pid})/%{category} %{function}: %{message}'
</syntaxhighlight>
or even better, to get colors:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
./kdesrc-build --debug <name>
c=`echo -e "\033"`
export QT_MESSAGE_PATTERN="%{appname}(%{pid})/(%{category}) ${c}[31m%{if-debug}${c}[34m%{endif}\
%{function}${c}[0m: %{message}"
unset c
</syntaxhighlight>
</syntaxhighlight>


Explore other options in the [https://kdesrc-build.kde.org/documentation/supported-cmdline-params.html official documentation]
Don't bother with KDEDIR and KDEHOME etc. this stuff isn't used anymore.


=Running plasma=
$ which ksnapshot
Save the following script as ~/kf5/runKrita5.sh
 
<syntaxhighlight lang="bash">
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.
#!/bin/bash
 
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.
if [ -d /etc/X11/xinit/xinitrc.d ]; then
  for f in /etc/X11/xinit/xinitrc.d/*; do
    [ -x "$f" ] && . "$f"
  done
  unset f
fi


DISTRO=`source /etc/os-release 2>/dev/null; echo $ID_LIKE`
$ eval `dbus-launch` # no console output expected, (kdeinit5 is started automatically when needed)
$ ksnapshot
export KF5=~/kf5/install
export QTDIR=/opt/qt5      # Change if you have your own qt build
export PATH=$KF5/bin:$QTDIR/bin:$PATH
export QT_PLUGIN_PATH=$KF5/lib/plugins:$KF5/lib64/plugins:$QTDIR/plugins:$QT_PLUGIN_PATH
#On some distros, this is $KF5/lib64/qml:$QTDIR/qml or something similar. After the installation, choose the directory/directories which contains the "qt/qml" folder.
export QML2_IMPORT_PATH=$KF5/lib/qml:$QTDIR/qml


#Fixes for Debian's "look at me, I'm so important" setups
= Running unit tests =
if [ $DISTRO == "debian" ]
Unit tests are ran from the build dir of each framework, you should first cd into it.
then
    export QT_PLUGIN_PATH=$KF5/lib/`uname -i`-linux-gnu/plugins:$QTDIR/plugins
    export QML2_IMPORT_PATH=$KF5/lib/`uname -i`-linux-gnu/qml:$QTDIR/qml
fi


export QML_IMPORT_PATH=$QML2_IMPORT_PATH
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).
export XDG_DATA_DIRS=$KF5/share:/usr/share
export XDG_CONFIG_DIRS=$KF5/etc/xdg:/etc/xdg
 
# Uncomment to change default home paths
#export XDG_DATA_HOME=$HOME/.kde5/local
#export XDG_CONFIG_HOME=$HOME/.kde5/config
#export XDG_CACHE_HOME=$HOME/.kde5/cache
exec startkde
</syntaxhighlight>


==Configuring dbus==
Because we installed Krita 3 to a custom path, we need to make dbus aware of these new locations.
Create a file /etc/dbus-1/session-local.conf with the following contents:
<pre>
<pre>
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
eval `dbus-launch`
  "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
kdeinit5
<busconfig>
make test
<servicedir>~/kf5/install/share/dbus-1/services</servicedir>
</pre>
</busconfig>
 
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 <pre>
xvfb-run -s '-screen 0 1024x768x24' make test
</pre>
(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 <tt>DBUS_SESSION_BUS_ADDRESS</tt> 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 [http://awesome.naquadah.org/ awesome] installed, you could create a script called <tt>awesome-run</tt> as follows: <syntaxhighlight lang="bash">
#!/bin/sh
awesome &
exec "$@"
</syntaxhighlight>
and then run the tests as <pre>
xvfb-run -s '-screen 0 1024x768x24' /path/to/awesome-run make test
</pre>
</pre>


Create another file /etc/dbus-1/system-local.conf with the following contents:
If you want to publish your test results, instead of "make test" run <pre>
<pre>
make Experimental
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<servicedir>~/kf5/install/share/dbus-1/system-services</servicedir>
<includedir>~/kf5/install/etc/dbus-1/system.d</includedir>
</busconfig>
</pre>
</pre>
The test results will appear on http://my.cdash.org/index.php?project=&lt;projectname&gt;
= 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 [https://community.kde.org/Frameworks/Building#Analyse_and_fix_build_errors Analyse and fix build errors]
4) Delete '''build''' and '''usr'''. Run kdesrcbuild again.
5a) Ask on IRC or mailing list (see [https://community.kde.org/Getinvolved/development#Communicating_with_the_team 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:
* https://community.kde.org/Plasma/5.1_Errata
* https://forum.kde.org/viewtopic.php?f=289&t=122996
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.


Because dbus will load all these new paths each time you login, you should rename these files (to eg system-local.conf.bk and session-local.conf.bk) before starting your default Krita 4 or other distro sessions.
2) Comment it out:
# module-set kf5-bluetooth-management
#    repository kde-projects
#    use-modules libbluedevil bluedevil
# end module-set


Finally, there are two ways of running Krita 3. Choose the one which suits you best.
Further calls of `kdesrcbild` will not include the component.


==Using a login manager==
== Runtime: Couldn't start kded5 (KDE4) ==
The recommended login manager is SDDM. But this should method work with any login manager.
(added: 2014-Dec)
<syntaxhighlight lang="bash">
 
sudo cp ~/kf5/runKrita5.sh /usr/share/xsessions
Situation: developing and executing KF5 apps under KDE 4.
sudo chmod +x /usr/share/xsessions/runKrita5.sh
 
sudo cp ~/kf5/install/share/xsessions/plasma.desktop  /usr/share/xsessions/plasmaGit.desktop
Problem by example: error message on console when starting ksnapshot in KF5 environment
</syntaxhighlight>
 
Edit /usr/share/xsessions/plasma.desktop and change the paths as:
<pre  style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: normal;">
<pre>
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
Exec=/usr/share/xsessions/runKrita5.sh
TryExec=/usr/share/xsessions/runKrita5.sh
Name=Krita Git
</pre>
</pre>
After this logout of your current session, select Krita Git in the options and login. You should now have the last Krita 3 running.


==From the command line==
Solution (not verified yet): as said in the article, run this command before starting the app itself:
Edit your xinitrc file:
<syntaxhighlight lang="bash">
. setup-kf5-env      # (or as your script is called)
mv ~/.xinitrc ~/.xinitrc.bk                # Backup any existing xinitrc file
eval `dbus-launch`    # no output expected
ln -s ~/kf5/runKrita5.sh ~/.xinitrc
ksnapshot            # no kded5 error message expected
</syntaxhighlight>
 
Log out of your current session, login to a tty (eg tty2 by pressing <code>Ctrl+Alt+F2</code>) and run <code>startx</code>. This should read your ~/.xinitrc and log you into a Krita 3 desktop.
== 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 ==


=Updating=
If you still have trouble with the building process or runtime setup you can contact people as described in [https://community.kde.org/Getinvolved/development#Communicating_with_the_team Communicating with the team].  
Run kdesrc-build each time you want the latest updates.
<syntaxhighlight lang="bash">
cd ~/kf5/sources/kdesrc-build
git pull                # First update kdesrc-build
./kdesrc-build --debug
</syntaxhighlight>


=Troubleshooting=
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:
You may not be able to successfully build or run Krita 3 at first go.
* You may not have all dependencies installed. Read the output to see what missing dependency it is complaining about, search for the corresponding package for your disto, and install it.
* If you get a build failure, simple fix might be to delete the build folder for that module and try building it again.
* Because we are compiling from the source code, some latest changes might be the cause of build failures. You may try going back to a previous code version (git skills required), wait sometime for the developers to fix the code, or even better, try to fix the build yourself and [https://techbase.kde.org/Development/Review_Board submit a patch] :)


For any help, [https://community.kde.org/Getinvolved/development#Communicating_with_the_team communicate with the KDE team].
* Gregor Mi (codestruct at posteo dot org) (build KF5 on openSUSE 13.2 running latest KDE 4)

Revision as of 12:19, 12 August 2015

Build requirements

This section provides information about hard (required) and optional software packages needed to build Qt5, Kf5 and Krita3.

Dependencies

These are the deps for Qt5 and Kf5: the extra dependencies for Krita also need to be installed (but you probably have them already)

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

  • 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
$ <your_AUR_helper> kf5-akonadi-git

Qt 5

Qt 5 (http://qt.io/) is the base of KDE software. Choose one of the following sections to get your Qt setup. If you build Qt with the intention to actually develop Qt patches then you should go for a full debug build. If you merely need Qt to develop KDE applications then you should go for the release with debug symbol version.

Note

ArchLinux users: qtwebkit and qtwebengine use Python to generate some files, but they use Python 2.x syntax. So you have to make python pointing to /usr/bin/python2, to do that see the Arch Wiki.


Qt5 full debug build

  • PRO: full control and debugging capabilities
  • CON: takes long to compile on the first time, might be an additional source of errors for beginners

To build all of qt5 execute:

git clone git://code.qt.io/qt/qt5.git --branch 5.4
cd qt5
./init-repository
./configure -prefix $PWD/qtbase -opensource -confirm-license -nomake tests -nomake examples \
  -dbus -no-separate-debug-info -xcb -system-xcb -qpa xcb -no-gtkstyle -developer-build
make

To update qt5 later:

git pull
git submodule sync
git submodule update --recursive

If you saw changes (i.e. qt5.git got updated since last time),

./configure [...same as above...]
make
echo $?    # you should make extra sure that 'make' didn't abort with an error, especially when using -j

Experimental and not officially supported: if you don't have enough time and disk space for all of qt5, you could restrict yourself to separate checkouts of qtbase.git, qtsvg.git, qtx11extras.git, qtscript.git and qttools.git, this is enough to build frameworks/* (but not enough for plasma-framework).

Qt5 release with debug symbols build

  • PRO: This build is the most ideal build when developing applications and tuning performance. It has the speed of a release build but with debug symbols which give you more information in for example kcachegrind with data collected through valgrind.
  • CON: The Qt libraries will be quite a lot bigger due to the debug symbols.

To build all of qt5 execute:

git clone git://code.qt.io/qt/qt5.git --branch 5.4
cd qt5
./init-repository
./configure -prefix $PWD/qtbase -opensource -confirm-license -nomake tests -nomake examples -dbus \
  -no-separate-debug-info -xcb -system-xcb -qpa xcb -no-gtkstyle -release -force-debug-info -reduce-relocations \
  -optimized-qmake
make

Use packages from your distribution

  • PRO: faster to get started, one source of errors less
  • CON: usually doesn't have debug symbols. Great for developing applications and measuring performance. Not so great for tuning performance (you'd need debug symbols for that).

Note that the Qt version currently must be >= 5.4

1) openSUSE:

$ sudo zypper install libqt5-qttools libgypsy0 libqt5-creator libqt5-linguist libqt5-qtbase-common-devel libqt5-qtbase-debugsource libqt5-qtbase-devel libqt5-qtbase-doc libqt5-qtbase-examples libqt5-qtdeclarative-debugsource libqt5-qtdeclarative-devel libqt5-qtdeclarative-examples libqt5-qtdeclarative-tools libqt5-qtdoc libqt5-qtgraphicaleffects libqt5-qtimageformats libqt5-qtimageformats-debugsource 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-debugsource 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

(these might be too much packages but with those the KF5 build worked)

2) Debian

  • For now, Qt >= 5.4 can only be found in experimental repository. If it's not already the case, add it to your sources list and update :
$ echo 'deb http://ftp.debian.org/debian experimental main' >> /etc/apt/sources.list
$ sudo apt-get update

$ sudo apt-get install -t experimental qtbase5-dev qtbase5-private-dev libqt5x11extras5-dev qtscript5-dev qttools5-dev libqt5svg5-dev libqt5xmlpatterns5-dev qttools5-dev-tools qtdeclarative5-dev

3) Other distributions: yet to be documented.

Alternative: compile KF5 into Docker

You can use Docker to keep your main system clean and avoid to install a lot of packages.

Follow the instructions given at the follow repository: https://github.com/Mathux/docker-kdesrc-build

Hints for openSUSE to get started:

1) install

sudo zypper install docker

2) If the error message

FATA[0000] Post http:///var/run/docker.sock/v1.16/images/create?fromImage=busybox%3Alatest: dial unix /var/run/docker.sock: no such file or directory 

appears whenever trying to execute any docker command then you have to start:

sudo systemctl start docker

3) Add your user to the docker group

4) Proceed as described in the github project.

5) Beware of low disk space on your root partition (see http://blog.eye48.com/post/98551740424/when-docker-io-eats-up-your-disc-space)

Build KDE Frameworks and its dependencies

Note

For instructions on building and running Plasma 5, see Plasma/Building.

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,

  1. download http://www.davidfaure.fr/kde/kf5-qt5-kdesrc-buildrc into your source dir
  2. 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
  • source-dir = where KDE Frameworks 5 sources should be downloaded
  • build-dir = where KDE Frameworks 5 should be built
  • kdedir = your KDE Frameworks 5 installation directory

Note: Append -std=c++11 to the cxxflags in the kdesrc-buildrc. Otherwise, you'll be no able to build libdbusmenu-qt.

Note

The value of kde-dir/share must be included in the environment variable XDG_DATA_DIRS or otherwise the build will fail. kdesrc-build should handle this for you.

Note

The Qt dir must be included in the environment variable CMAKE_PREFIX_PATH otherwise kdesrc-build will fail to configure most modules.


Run kdesrc-build

Note

Note that this script uses GIT and Bazaar to download the sources, so ensure you have both installed.

Note

Ensure that C++ compiler is g++. Building KDE with clang has linking errors.

You just have to run ./kdesrc-build to build the KDE Frameworks. It is the preferred way of building KDE Frameworks.

Note

kdesrc-build will only pick up the kdesrc-buildrc file you downloaded and edited above if it is in the same directory you run kdesrc-build from. If you save it to ~/.kdesrc-buildrc, however, it will be used no matter where you run kdesrc-build from.


If you want you can also do the work by hand following the detailed instructions: Frameworks/Building/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

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.

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

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

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

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:

  • Gregor Mi (codestruct at posteo dot org) (build KF5 on openSUSE 13.2 running latest KDE 4)