Difference between revisions of "Guidelines and HOWTOs/Build from source"

(Playing with syntax highlighting. Feel free to undo if you prefer how it was.)
(Everything on this page is now available on https://community.kde.org/Get_Involved/development, so make it a redirect to that page)
Tag: New redirect
 
(316 intermediate revisions by 62 users not shown)
Line 1: Line 1:
= Build requirements =
+
#REDIRECT [[Get Involved/development]]
This section provides information about '''hard''' (required) and '''optional''' software packages needed to build the KDE Framework.
 
 
 
=== Dependencies ===
 
*'''deb-based distributions (Debian, Ubuntu...):'''
 
$ sudo apt-get build-dep qt4-x11
 
$ 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
 
 
 
*'''OpenSuSE:''' All the necessary dependencies:
 
$ sudo zypper si -d libqt4
 
$ 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
 
 
 
*'''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 bzip2-devel libxslt-devel libxml2-devel shared-mime-info oxygen-icon-theme giflib-devel doxygen xcb-util-keysyms-devel perl-Pod-Usage "*xcb*-devel" perl-XML-Parser
 
 
 
*'''Arch Linux:''' All the dependencies used for building frameworks can be installed by running:
 
$ sudo pacman -Sy phonon-qt5 qt5-webkit qt5-svg qt5-x11extras enchant jasper openexr libutempter docbook-xsl shared-mime-info giflib libxss upower udisks2
 
$ <your_AUR_helper> kf5-attica-git libdbusmenu-qt5 kf5-akonadi-git kf5-polkit-git
 
 
 
=== Qt 5 ===
 
To build all of qt5 execute:
 
<syntaxhighlight lang="bash">
 
git clone git://anongit.kde.org/qt/qt5.git --branch stable
 
cd qt5
 
./init-repository
 
./configure -prefix $PWD/qtbase -opensource -confirm-license -developer-build -nomake tests -nomake examples -dbus -no-separate-debug-info -xcb -qpa xcb -no-gtkstyle
 
make
 
</syntaxhighlight>
 
 
 
To update qt5 later:
 
<syntaxhighlight lang="bash">
 
git pull
 
git submodule sync
 
git submodule update --recursive
 
</syntaxhighlight>
 
 
 
To switch to stable branch if you had dev branch (now kf5 depends against 5.2)
 
<syntaxhighlight lang="bash">
 
git checkout stable
 
git pull
 
git submodule sync
 
git submodule update --recursive
 
</syntaxhighlight>
 
 
 
If you saw changes (i.e. qt5.git got updated since last time),
 
<syntaxhighlight lang="bash">
 
./configure [...same as above...]
 
make
 
echo $?    # you should make extra sure that 'make' didn't abort with an error, especially when using -j
 
</syntaxhighlight>
 
 
 
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 and qtx11extras.git, this is enough to build  frameworks/* (but not enough for plasma-framework).
 
 
 
<b>NOTE for ArchLinux users</b>: qtwebkit uses python to generate some files, but it uses python2 syntax. So you have to either [https://projects.archlinux.org/svntogit/packages.git/plain/trunk/use-python2.patch?h=packages/qt5 patch the qtwebkit code] or make /usr/bin/python point to /usr/bin/python2. See also https://wiki.archlinux.org/index.php/Python
 
 
 
= Runtime setup =
 
To use your new KF5 install prefix (let's call it $KF5) :
 
<pre>
 
export KF5=<path to your intended frameworks install directory>
 
export QTDIR=<path to your qt5 sources>/qtbase
 
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 KDE_SESSION_VERSION=5
 
export KDE_FULL_SESSION=true
 
</pre>
 
 
 
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:
 
<pre>
 
export XDG_DATA_HOME=$HOME/.local5
 
export XDG_CONFIG_HOME=$HOME/.config5
 
export XDG_CACHE_HOME=$HOME/.cache5
 
</pre>
 
 
 
To be able to compile other stuff on top of KF5:
 
<pre>
 
export CMAKE_PREFIX_PATH=$KF5:$CMAKE_PREFIX_PATH
 
</pre>
 
 
 
To get more information out of qDebug statements (i.e. make it more like kDebug) :
 
<pre>
 
export QT_MESSAGE_PATTERN='%{appname}(%{pid})/%{category} %{function}: %{message}'
 
</pre>
 
or even better, to get colors:
 
<pre>
 
c=`echo -e "\033"`
 
export QT_MESSAGE_PATTERN="%{appname}(%{pid})/(%{category}) $c[31m%{if-debug}$c[34m%{endif}%{function}$c[0m: %{message}"
 
unset c
 
</pre>
 
 
 
Don't bother with KDEDIR and KDEHOME etc.  this stuff isn't used anymore.
 
 
 
=== 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:
 
 
 
= Build KDE Frameworks and its dependencies =
 
== Clone kdesrc-build ==
 
First you need kdesrc-build, it can be done with the following commands:
 
<pre>
 
mkdir -p extragear/utils
 
git clone kde:kdesrc-build extragear/utils/kdesrc-build
 
ln -s extragear/utils/kdesrc-build/kdesrc-build .
 
</pre>
 
 
 
== 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:
 
<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>
 
  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 qt5 sources are located
 
* source-dir = where KDE Frameworks 5 sources should be downloaded
 
* build-dir = where KDE Frameworks 5 should be built
 
* kde-dir = your KDE Frameworks 5 installation directory
 
 
 
{{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.}}
 
 
 
== Build kdesrc-build ==
 
{{Note|Note that this script uses GIT and Bazaar to download the sources, so ensure you have both installed. }}
 
You just have to run <code>./kdesrc-build</code> 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: [[Frameworks/Building/Details]].
 
 
 
== Use project neon 5 tools ==
 
Project Neon 5 in KUbuntu provides neon5-env and neon5-cmake tools which makes building KDE Frameworks easy. For more details see: http://community.kde.org/Frameworks/Building/ProjectNeon5
 
 
 
= 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).
 
 
 
<pre>
 
eval `dbus-launch`
 
kdeinit5
 
make test
 
</pre>
 
 
 
Warning: never start a KDE4 application in this separate DBus session, it would conflict with your running KDE4 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 &
 
 
</syntaxhighlight>
 
and then run the tests as <pre>
 
xvfb-run -s '-screen 0 1024x768x24' /path/to/awesome-run make test
 
</pre>
 
 
 
If you want to publish your test results, instead of "make test" run <pre>
 
make Experimental
 
</pre>
 
The test results will appear on http://my.cdash.org/index.php?project=&lt;projectname&gt;
 

Latest revision as of 21:00, 25 July 2020


This page was last edited on 25 July 2020, at 21:00. Content is available under Creative Commons License SA 4.0 unless otherwise noted.
-->