Getting Started/Build/KDE Applications

Jump to: navigation, search

Introduction

The process to build applications is easy. It can get tedious in the beginning but with time it's easy to understand.

In this page I'll discuss the compilation and installation of a simple KDE application or project on a regular GNU/Linux system. It can get more complicated but I'd prefer to keep this document simple.

Preparing your system a little

First of all you probably will need to know the dependencies to compile the program you want to compile. In my experience, a great portion of the problems that people have forgot to install the development packages for the system libraries. Keep that in mind.

In general, the needed packages will be: cmake, git-core, libqt4(-dev), kdelibs(-dev). Depends on the distribution but the naming should be something like this.

Steps

Here we will try to compile an application, let's say blinken. You can find information about all KDE software at the KDE Projects page

First we will download the code

git clone git://anongit.kde.org/blinken


This will create a directory with blinken's source code inside. We also create a directory to contain the files generated during the build process, and change into that directory.

cd blinken; mkdir build; cd build


Now we'll set up the development system by calling cmake. We're passing two parameters here: CMAKE_INSTALL_PREFIX indicates where the application will be installed, and CMAKE_BUILD_TYPE has the value "debugfull" to tell CMake not to throw away information that is useful for developers.

cmake .. -DCMAKE_INSTALL_PREFIX=<install_path> -DCMAKE_BUILD_TYPE=debugfull

If you just want to install it in the same place as the rest of KDE, you can do

cmake .. -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` -DCMAKE_BUILD_TYPE=debugfull


The moment we were all expecting has arrived, now you can start compiling.

make -j3

The -j3 option tells make to try to do up to three things at once. A good rule for this option is to add one to the number of cores your computer has. In this example, we're assuming you have a dual-core computer (which is fairly common). If you have a quad-core computer, you may want to pass -j5. If you want to do other things on your computer at the same time, you may want to lower the number.

Some applications can work without installing but that's usually not the case so just do it if you know what you're doing, otherwise you will want to install probably.

make install


If you're installing it to a directory where the owner is root, then you'll probably need some extended privileges to install. That's not the only option, though. You can create a specific install directory by pointing the PATH and KDEDIRS variables to it, more information here: Getting_Started/Build/Environment


This page was last modified on 15 October 2012, at 12:34. This page has been accessed 5,763 times. Content is available under Creative Commons License SA 3.0 as well as the GNU Free Documentation License 1.2.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal