Monday, October 31, 2016

Building KDE Plasma 5.8 for CentOS 7

You're probably like me- one of those people searching all over the forums and the far reaches of Google trying to find that ONE person who is trying to do this. You've probably come across quite a few of those people who tell you to use a different distro. But if you're like me and you have been challenged with getting KDE Plasma 5 to work on CentOS, you simply cannot just take that as an answer. Well I'm here to help share my war stories and ballads of victory so that you can hold your head up high (and perhaps save your self a few hours to days trying to source all the information yourself through trial and error).

I am not responsible for anything you do following these instructions to mess up your current system. Do so at your own risk! I will be guiding you NOT how to officially install Plasma into a production environment but how to BUILD KDE for testing/debugging/exploration/personal research. This is all unstable and a few things may or may not work so it is up to you to troubleshoot on your own or source the wonderful KDE community.

This Tutorial will get you to a basic Plasma Desktop session.
This based on the current git distribution at the time of writing this: KDE Plasma 5.8.90

(Note: Some of this information comes directly from the KDE build documentation, and some I have adapted for CentOS 7. I will link to the KDE Documentation at the end of this post.)

1. From Scratch / Getting the Repos

I will be starting from a CentOS7 Minimal install ( This has nothing, no xserver, no GUI, just good old terminal).

To begin, I’m starting with a fresh minimal install of CentOS 7 with all updates.

  • Install Git
  •  sudo yum install git  
  • Enable EPEL Repos
  •  sudo yum install epel-release

  • Install compilers
  •  sudo yum group install "Development Tools"

  • Install lsb
  •  sudo yum install lsb

  • Install cpanminus
  •  sudo yum install cpanminus

To compile KDE Plasma 5 on CentOS 7, you must have CMAKE3 and the Qt5 environment.
These are not avaliable in normal repos, which is why we needed to ad the EPEL.

  • Install CMake3
  •  sudo yum install cmake3
  • Install all QT5 with wildcard to get all the repos.
  •  sudo yum install qt5-*
  • Link cmake in CentOS 7 to CMake3 in the /usr/bin directory for the compiler.
  •  sudo ln -s /usr/bin/cmake3 /usr/bin/cmake

In order to build KDE Plasma 5, whether or not you will use Wayland, you must have the wayland development files in place. This is not available through the normal repos so it must be added manually.

  • First, you will need wget to get the needed repos
  • sudo yum install wget
  • For the purposes of CentOS you will be using xorg, so install only the development files.
  • sudo yum install wayland-devel libwayland-client-devel libwayland-cursor-devel libwayland-server-devel

2. Get the Dependencies

I am making this it's own section because there are A LOT of them. It took me about 2 days on and off to put this list together so that hopefully you can save all the time I did and install all the needed developer libraries in one big swift yum install.

If the git updates (and it will) and requirements change (and it will) you may have add or change a few to this list, but hopefully this is it and this is all you will have to do for now.

First I will list out all the dependencies by numbers and then follow up with the all-in-one yum install copy and paste. I do this to help me keep track and hopefully it helps you too.

Compilation Dependencies as of KDE Plasma-Desktop 5.8.90:

  1. boost-devel
  2. catdoc
  3. dbus-x11
  4. docbook-dtds
  5. docbook-style-xsl
  6. exiv2-devel
  7. giflib-devel
  8. libattr-devel
  9. libepoxy-devel
  10. libevdev-devel
  11. libinput-devel
  12. libjpeg-devel
  13. libpng-devel
  14. libSM-devel
  15. libwayland-client-devel
  16. libwayland-cursor-devel
  17. Libwayland-server-devel
  18. libXcursor-devel
  19. libxkbcommon-devel
  20. libxkbcommon-x11-devel
  21. libxkbfile-devel
  22. libxml2-devel
  23. libXrender-devel
  24. libxslt-devel
  25. lmdb-devel
  26. mesa-libgbm-devel
  27. NetworkManager-devel
  28. NetworkManager-libnm-devel
  29. openssl-devel
  30. pam-devel
  31. polkit-devel
  32. polkit-qt5-1-devel
  33. poppler-qt5-devel
  34. systemd-devel
  35. taglib-devel
  36. xapian-core-devel
  37. xcb-util-cursor-devel
  38. xcb-util-devel
  39. xcb-util-image-devel
  40. xcb-util-keysyms-devel
  41. xkeyboard-config-devel
  42. xorg-x11-drv-evdev-devel
  43. xorg-x11-drv-synaptics-devel
  44. xorg-x11-server-devel
  45. xorg-x11-xkb-utils-devel
All compiled into a single yum install (hopefully)

sudo yum install boost-devel catdoc dbus-x11 docbook-dtds docbook-style-xsl exiv2-devel giflib-devel libattr-devel libepoxy-devel libevdev-devel libinput-devel libjpeg-devel libpng-devel libSM-devel libwayland-client-devel libwayland-cursor-devel Libwayland-server-devel libXcursor-devel libxkbcommon-devel libxkbcommon-x11-devel libxkbfile-devel libxml2-devel libXrender-devel libxslt-devel lmdb-devel mesa-libgbm-devel NetworkManager-devel NetworkManager-libnm-devel openssl-devel pam-devel polkit-devel polkit-qt5-1-devel poppler-qt5-devel systemd-devel taglib-devel xapian-core-devel xcb-util-cursor-devel xcb-util-devel xcb-util-image-devel xcb-util-keysyms-devel xkeyboard-config-devel xorg-x11-drv-evdev-devel xorg-x11-drv-synaptics-devel xorg-x11-server-devel xorg-x11-xkb-utils-devel

3. Git and Getting it

Now we will need to setup the build directory and the place we will download our git repos. For the sake of easy testing and building for all users I will create the folders under /opt/kde/src, but you can do as you wish. Make sure to substitute any /opt/kde for whatever directory you wish to do going forward.

  • Create source directory.
  •  ssudo mkdir -p /opt/kde/src

  • Let’s make it yours for now.
  •  sudo chown YOURNAME -R /opt/kde

Since you, or at least I, changed the ownership here, I no longer need sudo on a lot of these commands going forward, just to make testing easier on myself.

Setting up Git for the first time. If you already have you can skip this small part.
git config --global “Your Name”
git config --global

Now you should have in your ~/ directory a .gitconfig file.
We will set up some KDE environment shortcuts.
  • Open ~/.gitconfig with your favorite text editor (vi, emacs, nano, ect)
  • A the bottom, append the following:

[url "git://"]
     insteadOf = kde:
[url "ssh://"]
     pushInsteadOf = kde:

You are now ready to pull down the source and set up a build template.
  • From /opt/kde/src run 
  •  git clone kde:kdesrc-build
  • Go into the new folder kdesrc-build
  •  cd kdesrc-build
  • Copy the sample build script to your home directory 
  •  cp kdesrc-buildrc-kf5-sample ~/.kdesrc-buildrc
  • We will also need to add the path variable for the kdesrc-build. Enter the following lines:

mkdir ~/bin
ln -s $PWD/kdesrc-build ~/bin
export PATH=~/bin:$PATH

  • You will also need to append the following line to the bottom of your ~/.bashrc file:
  •  export PATH=~/bin:$PATH
In the .kdesrc-buildrc file you originally copied, you can honestly replace or enter the text to match the following: (note: on make-options -j4 below, that is -j and the number of cores you have plus one more. So if you have 4 cores you can do make-options -j5)

    Branch-group kf5-qt5
    source-dir  /opt/kde/src
    build-dir  /opt/kde/build
    log-dir  /opt/kde/log
    kdedir  /opt/kde/install
    qtdir /usr

    git-repository-base     kde-projects kde:

    cmake-options -DCMAKE_BUILD_TYPE:STRING=debug

    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 -std=c++11

    make-options -j5
    ignore-kde-structure    true       
    stop-on-failure         true 
end global

include /opt/kde/src/kdesrc-build/kf5-frameworks-build-include
include /opt/kde/src/kdesrc-build/kf5-workspace-build-include

options kcoreaddons
     cmake-options -j5
end options

 options baloo
     cmake-options -DCMAKE_CXX_FLAGS="-lc"
 end options

Save and run from /opt/kde/src/kdesrc-build directory:

 kdesrc-build --debug --include-dependencies plasma-desktop

Congratulations (Hopefully) you are now on the semi-long period of compiling.

Note that this is JUST for the plasma desktop environment, not any of the other applications, such as Kate, Dolphin, ect, but I will address building those the next blog post. For now, let's get you able to get into the KDE Plasma 5 desktop.

4. Successfully Compiled? Good. Install a tiny bit more.

First things first, you will still need to get your Xorg environment installed.

  • Install the Xorg (X Window System) 
  •  sudo yum groupinstall “X Window System”
  • Install needed system Fonts to read stuff.
  •  sudo yum groupinstall “Fonts”

Now you must create a bash file to launch KDE in it's sandboxed testing environment.
To do this, create a new file in your favorite text editor (in my case) /opt/kde/  and call it

CentOS 7 likes to put it's libraries around a little different and you will find that debian/ubuntu scripts do not match to this, but this is what works for CentOS 7 (please also note my custom directories, change yours to match) :

if [ -d /etc/X11/xinit/xinitrc.d ]; then
  for f in /etc/X11/xinit/xinitrc.d/*; do
    [ -x "$f" ] && . "$f"
  unset f

export KF5=/opt/kde/install
export QTDIR=/usr/lib64/ 
export PATH=$KF5/bin:$QTDIR/bin:$PATH
export QT_PLUGIN_PATH=$KF5/lib/plugins:$KF5/lib64/plugins:$QTDIR/plugins:$QT_PLUGIN_PATH

export QML2_IMPORT_PATH=$KF5/lib64/qml:$QTDIR/qml

export XDG_DATA_DIRS=$KF5/share:/usr/share
export XDG_CONFIG_DIRS=$KF5/etc/xdg:/etc/xdg
exec startkde

  • Now make this file executable and ready to copy around.
  •  sudo chmod +x /opt/kde/
  • We will now need to copy this file over to to xsessions.
  •  sudo cp /opt/kde/ /usr/share/xsessions/
  • We will also need to link this to the users local .xinitrc file for startx to work.
  •  sudo ln -s /usr/share/xsessions/ ~/.xinitrc

5. Fire up Xorg and see KDE Plasma 5 Destop.

  • Start up the xorg xserver under your current user.
  •  startx

It is important to note that at this point, you are not going to be booting INTO KDE Plasma 5 Desktop. If you already know how to get your GDM, SDDM, KDM or whatever you want connected up and ready to go, all the power to you and have at it. 

To install SDDM (recommended if you want to use the Breeze theme like KDE Neon)

  • Install SDDM (this comes from the EPEL repo)
  •  sudo yum install sddm
  • Enable SDDM service
  •  sudo systemctl enable sddm
You will them have a Desktop Manager and login screen you can use, default SDDM theme.

In the next post, I will cover compling the typical applications under the KDE environment and what dependencies may be required to get us to a more fully functional desktop.

Have fun and enjoy your not so impossible CentOS7 with the latest KDE.

ANOTHER IMPORTANT NOTE: You may want to turn off Screen Locking under System Settings -> Desktop Behavior. As of right now, it seems no matter what password you put in, it will say that the password is wrong and will not let you back into your desktop, requiring you to CTRL-ALT-F(whatever) to get to a terminal and get back in.

As mentioned earlier, the source for a lot of the basics to building KDE with some examples on how to set up test environments and even an Ubuntu 14.04 build example: