KDE/Developing/Guide

From openSUSE

< KDE

Contents

Build Guide for KDE on openSUSE

Building KDE 4

Why use this guide? The KDE Team at openSUSE are a group of fanatical KDE developers who work hard to make it easy to use and develop KDE on openSUSE. By using our precompiled packages accessible via One Click Install, you can cut out the hassle of building qt-copy, or other KDE support libraries like Soprano or QCA2. Since we are very close to the KDE release team, our packages include all the patches KDE trunk needs and are always up to date. This saves you time and effort in tracking the latest innovations as KDE moves towards KDE 4.1.

This guide does not use a magic build script to do everything for you. Instead it shows you how to build KDE by hand with a few easy steps and a couple of simple helpers to prevent mistakes.

The following instructions show you how to build KDE 4 SVN trunk on openSUSE 10.3. They don't assume any prerequisites besides a freshly installed 10.3.


Install software needed to build KDE 4

  • Ensure the online community repositories are enabled. Open YaST2, go to Software, Community Repositories. Make sure that 'Main Repository OSS' is checked. Click Finish.
  • Install the packages required for general KDE development: Open the Software Management module of YaST2 and select Patterns in the Filter combo box. Scroll down to the Development section and select 'KDE Development'. Click Accept.
  • Install the KDE 4 development prerequisites: These are located in the openSUSE Build Service. You can install them using One Click Install with this link to KDE 4 build dependencies.
  • Install optional dependencies. These packages are not strictly needed to build KDE 4, and give optional functionality:
    • libjasper-devel : used for the JPEG2000 image format.
    • enchant-devel : a spell checking library abstraction, used by Sonnet
    • OpenEXR-devel : access images in EXR format.
    • libraw1394-devel : used to show FireWire devices in KInfoCenter
    • pciutils-devel : used to show information on PCI devices in KInfoCenter

If you are sick of the sight of the Software Management YaST module already, just use

 zypper in libjasper-devel enchant-devel OpenEXR-devel libraw1394-devel pciutils-devel

as root in a shell.

Setup a build environment for KDE 4

The environment is a set of shell variables that specify where to find the tools and libraries you installed in the previous step, and sets where KDE 4 is to be installed. KDE and openSUSE have provided a set of scripts that set up the environment for building KDE 4, and for running it:

Save these scripts somewhere handy. You may want to edit them to suit your system. By default they put everything in $HOME/kde - sources, builds and the installed KDE 4. If you want more than one user to use this hand-built KDE4, a more central location is more appropriate. The storage requirements for a KDE development build (on i586, with gcc 4.2) are

  • source - libs, pimlibs, base: 682Mb
  • build - libs, pimlibs, base: 3.8Gb
  • install - libs, pimlibs, base 1.6Gb

These numbers are so large because of the size overhead of building with full debugging symbols.

If you edit the variables, the ones you are most likely to change are KDE_DEVEL_PREFIX in kde4-build-env and KDE_INSTALL_PREFIX in kde4-run-env. Note also that these scripts set KDEHOME to $HOME/.kde4, so that KDE 4 applications will not overwrite KDE 3 applications' settings.

When you have customised the scripts to meet your needs, source the build script into your current environment (The build script sources the runtime script internally) :

 . kde4-build-env

Yes, that's a full stop or period character on its own.

Obtain the KDE 4 SVN trunk sources

As you are probably not a KDE developer with an account on the SVN server, we use the anonymous SVN mirrors for public access to download the KDE 4 trunk sources.

First, switch to the source directory:

 cd ~/kde/sources

Now, get the root of KDE SVN trunk:

 svn checkout -N svn://anonsvn.kde.org/home/kde/trunk

We use -N to only get one directory at a time, not all of its contents.

Next, change into the root you just checked out:

 cd trunk

And get the root of the main KDE modules that make up a KDE release

 svn up -N KDE

Then, change into 'KDE' and get the basic modules comprising KDE 4. This can take some time:

 cd KDE
 svn up kdelibs kdepimlibs kdebase

kdelibs are the basic libraries comprising the KDE Platform. kdepimlibs are specialised libraries for Personal Information Management, and are also required. The last mandatory component, kdebase, contains the basic runtime elements of KDE as well as the programs that make up the workspace such as Plasma.

Build the KDE 4 sources

We're now ready to begin the build process. If you have more than one Linux computer you may want to take a detour to the Icecream build farm page, because Icecream, a distributed build system developed by SUSE, can reduce the time it takes to build a large project like KDE 4 enormously.

Change into the kdelibs source tree:

 cs KDE/kdelibs

'cs' is a shell function defined in in kde4-build-env which stands for 'Change [To] Sources'. It won't work unless you sourced kde4-build-env already. Without any argument it takes you to the root of the KDE sources tree.

And start the build:

 cmakekde

While kdelibs build, you could look at kde4-build-env to see what cmakekde does. Basically it switches you to the build dir, creating it if needed, sets up the build system ('cmake' is the equivalent of the well known './configure' here), builds and, all being well, installs the result. Once you have run cmakekde once, you can also just use 'make -j2 install'.

When kdelibs has built, repeat the process, in order, for kdepimlibs and kdebase:

 cs KDE/kdepimlibs
 cmakekde
 cs KDE/kdebase
 cmakekde

If something goes wrong

Remember you are using KDE 4 trunk. There is no guarantee that it will build at any given time. You can check the KDE Dashboard, an automated service that frequently rebuilds KDE 4 from scratch to check for errors. If a module won't build, but is green in Dashboard, check that you have at least that version of trunk in your working copy (svn up $MODULENAME in sources/trunk/KDE). If that doesn't help, 'make clean' in that module to clean out old built code and make again. If all else fails, try #opensuse-kde or #kde-devel on FreeNode for help.

Running KDE 4

You can start KDE 4 two ways; by hand from a text console, or as usual via KDM or any other display manager. We'll go briefly over the manual method first, as this can help troubleshooting when the easier KDM route fails.

Important

kde4-run-kde sets KDEHOME to ~/.kde4 . If you run KDE3 apps in this environment, they will also save their data and config to KDEHOME. This is not supported. Before running a KDE 3 app, unset KDEHOME or clean the environment entirely, for example, with su - youruser.

Starting a KDE 4 session manually

  • Switch to a text console:
 <ctrl> <alt> <F1>
  • Login
  • Setup the KDE4 runtime environment
 . kde4-run-env
  • Start the DBus session. DBus is normally started automatically for you by the display manager.
 . eval `dbus-launch --auto-syntax`
  • Start the X server.
 export DISPLAY=:1
 X -novtswitch $DISPLAY
  • Start KDE 4
 startkde
  • Lastly, switch to the X server. KDE 4 will be starting up - the first start takes some time as the system configuration cache has to be created from scratch - and after the splash screen disappears, you should see the familiar Plasma desktop
 <ctrl> <alt> <F8>

Using a display manager to start KDE 4

We've provided a pair of files that you will need to install to your system to tell the display manager how to start KDE 4.

  • kde4-svn-trunk.desktop - save this in /usr/share/xsessions .
  • kde4-launch - edit this so it sources kde4-run-env from where you saved it, then save it in /usr/local/bin and make it executable:
chmod 755 /usr/local/bin/kde4-launch

Once you've followed these steps, start a new session (K Menu->Leave->Switch User) and "KDE 4 SVN Trunk" will be selectable in the Session Type menu.

If you get a KDE 3 session after logging in from the display manager, you didn't read the bit about editing kde4-launch above.

Next steps

Build more modules

So far you only checked out and built the minimal set of KDE modules. To get a useful desktop you will have to checkout other modules. You can see the other modules by switching into sources/trunk/KDE and doing a

 svn ls

kdegraphics, kdemultimedia, kdepim, kdenetwork are some of the more important modules. To get amarok or digikam, in sources/trunk, svn up extragear/multimedia or extragear/graphics. Digikam requires kipi-plugins, which are in extragear-libs, so build this first!

Stay up to date

cs KDE
svn up kde*

Useful Resources