Guidelines and HOWTOs/Build from source: Difference between revisions

From KDE Community Wiki
(explain why a separate dbus session is needed)
Line 114: Line 114:
   $ make
   $ make
   $ make install
   $ make install
<b>NOTE for ArchLinux users</b>: qtwebkit uses python to generate some files, but it uses python2 syntax. So if you have installed python3, you'll get a compilation error on the file itab.py bevause print is no longer a statement, but a function. So, you would like to make /usr/bin/python to point to /usr/bin/python2. See also https://wiki.archlinux.org/index.php/Python


At this point you can continue building things by hand, or download http://www.davidfaure.fr/2012/kf5-qt5-kdesrc-buildrc into your source dir, adjust the paths and run kdesrc-build.
At this point you can continue building things by hand, or download http://www.davidfaure.fr/2012/kf5-qt5-kdesrc-buildrc into your source dir, adjust the paths and run kdesrc-build.

Revision as of 14:25, 24 December 2012

Build requirements

This section provides information about hard (required) and optional software packages needed to build the KDE Framework.

Kdelibs packages

  • deb-based distributions (Debian, Ubuntu...): All the dependencies used for the packages can be installed by running
$ apt-get build-dep {packagename}
  • for instance on Ubuntu:
$ sudo apt-get build-dep kdelibs5
  • OpenSuSE: All the dependencies used for building kdelibs can be installed by running:
$ zypper si -d kdelibs5
  • Fedora: All the dependencies used for building kdelibs can be installed by running:
$ yum-builddep kdelibs5

CMake 2.10.1

You need CMake 2.10.1 for KDE Frameworks 5. If you are already using 2.10.1 you can move on to next step else download it from http://www.cmake.org/cmake/resources/software.html.

Alternative for CMake 2.10.1 using Git.

  • Choose an install prefix, for instance
 $ export KF5=$HOME/kf5

To avoid repetition of command you can append ~/.bashrc file with above line and execute,

 $ source ~/.bashrc  
  • Checkout and install Latest version of CMake using Git.
 $ git clone git://cmake.org/cmake.git
 $ cd cmake
 $ ./configure --prefix=$KF5
 $ make
 $ make install

Extra CMake Modules

  • Checkout and build extra-cmake-modules
 $ git clone git://anongit.kde.org/extra-cmake-modules
 $ cd extra-cmake-modules
 $ cmake -DCMAKE_INSTALL_PREFIX=$KF5 . 
 $ make 
 $ make install

Build KDE frameworks

Current state of KDE framework exist in frameworks branch of kdelibs.

To retrieve the source code from Git you have to use the following setup.Add the following text to your ~/.gitconfig:

 [url "git://anongit.kde.org/"]
    insteadOf = kde:
 [url "ssh://[email protected]/"]
    pushInsteadOf = kde:

Then execute

 $ git clone kde:kdelibs --branch frameworks
 $ mkdir  kdelibs/build 
 $ cd kdelibs/build 
 $ cmake -DCMAKE_INSTALL_PREFIX=$KF5 -DCMAKE_SYSTEM_PREFIX_PATH=/usr:/usr/local:$KF5 ..
 $ make
 $ make install

Updating the already built framework. If the source code has been checked from a branch, it is possible to update the source code with newly added changes and build again. Usually only changing parts will be built, so this operation would be faster than building the source code from scratch.

Go to your source directory and execute following commands.

 $ git pull --rebase
 $ cd build
 $ make
 $ make install

Runtime setup

To use your new KF5 install prefix (let's call it $KF5) :

export XDG_DATA_DIRS=$KF5/share:$XDG_DATA_DIRS
export XDG_CONFIG_DIRS=$KF5/etc/xdg:$XDG_CONFIG_DIRS
export PATH=$KF5/bin:$PATH
export QT_PLUGIN_PATH=$KF5/lib/plugins:$QTDIR/plugins:$QT_PLUGIN_PATH
   (lib64 instead of lib, on OpenSUSE)

To use separate user settings for KF5:

export XDG_DATA_HOME=$HOME/.local5
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

Don't bother with KDEDIR and KDEHOME etc. this stuff isn't used anymore.

Running unit tests

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

Warning: never start a KDE4 application in this separate DBus session, it would conflict with your running KDE4 desktop.

Building KDE frameworks with Qt 5

The recommended way to do this is to install Qt5, Phonon 5, and the patched libdbusmenu-qt in your $KF5 directory, and pass -DCMAKE_PREFIX_PATH=$KF5 to cmake when building KDE Frameworks. More details below.

To build qt5 execute:

 $ git clone git://gitorious.org/qt/qt5.git
 $ cd qt5
 $ ./init-repository
 $ mkdir build
 $ cd build
 $ ../configure -prefix $KF5 -opensource -confirm-license -nomake examples -qpa xcb -no-gtkstyle
 $ make
 $ make install

NOTE for ArchLinux users: qtwebkit uses python to generate some files, but it uses python2 syntax. So if you have installed python3, you'll get a compilation error on the file itab.py bevause print is no longer a statement, but a function. So, you would like to make /usr/bin/python to point to /usr/bin/python2. See also https://wiki.archlinux.org/index.php/Python

At this point you can continue building things by hand, or download http://www.davidfaure.fr/2012/kf5-qt5-kdesrc-buildrc into your source dir, adjust the paths and run kdesrc-build.

To build phonon by hand execute:

 $ git clone kde:phonon --branch five
 $ mkdir phonon/build
 $ cd phonon/build
 $ cmake -DCMAKE_INSTALL_PREFIX=$KF5 -DCMAKE_PREFIX_PATH=$KF5 ..
 $ make
 $ make install

To build the patched libdbusmenu-qt execute:

 $ bzr branch lp:libdbusmenu-qt
 $ wget http://www.davidfaure.fr/2012/libdbusmenu-qt.diff
 $ cd libdbusmenu-qt
 $ patch -p0 -i ../libdbusmenu-qt.diff
 $ mkdir build
 $ cd build
 $ cmake -DCMAKE_INSTALL_PREFIX=$KF5 -DCMAKE_PREFIX_PATH=$KF5 ..
 $ make
 $ make install

At this point, building KDE Frameworks works just the same as with Qt4.

Qt5-specific setup instructions

export QT_MESSAGE_PATTERN='%{appname}(%{pid})/%{category} %{function}: %{message}'

so that qDebug behaves almost like kDebug.