Difference between revisions of "Getting Started/Build/KDE Applications"

Jump to: navigation, search
(Created page with "= 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 ...")
 
(Steps: Improve the language, and give a couple of extra useful hints.)
 
(2 intermediate revisions by 2 users not shown)
Line 11: Line 11:
 
= Steps =
 
= Steps =
  
Here we will try to compile an application, let's say blinken. You can find a full compendium of the KDE projects in http://projects.kde.org
+
Here we will try to compile an application, let's say blinken. You can find information about all KDE software at the [http://projects.kde.org KDE Projects page]
  
 
First we will download the code
 
First we will download the code
  
git clone kde:blinken
+
<syntaxhighlight lang="bash">
 +
git clone git://anongit.kde.org/blinken
 +
</syntaxhighlight>
  
This will create a directory with blinken's source code inside. We get in and we create a directory where it's going to be built
 
  
cd blinken; mkdir build; cd build
+
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.
  
Now we'll set up the development system by calling cmake. We're passing two parameters here CMAKE_INSTALL_PREFIX that will tell where the application will be installed and CMAKE_BUILD_TYPE that will tell the optimization of the produced binaries. (not entirely accurate, but there's heaps of documentation about that).
+
<syntaxhighlight lang="bash">
 +
cd blinken; mkdir build; cd build
 +
</syntaxhighlight>
 +
 
 +
 
 +
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.
 +
<syntaxhighlight lang="bash">
 +
cmake .. -DCMAKE_INSTALL_PREFIX=<install_path> -DCMAKE_BUILD_TYPE=debugfull
 +
</syntaxhighlight>
 +
If you just want to install it in the same place as the rest of KDE, you can do
 +
<syntaxhighlight lang="bash">
 +
cmake .. -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` -DCMAKE_BUILD_TYPE=debugfull
 +
</syntaxhighlight>
  
cmake .. -DCMAKE_INSTALL_PREFIX=<install_path> -DCMAKE_BUILD_TYPE=debugfull
 
  
 
The moment we were all expecting has arrived, now you can start compiling.
 
The moment we were all expecting has arrived, now you can start compiling.
  
make
+
<syntaxhighlight lang="bash">
 +
make -j3
 +
</syntaxhighlight>
 +
The <tt>-j3</tt> 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 <tt>-j5</tt>.  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.
 
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
+
<syntaxhighlight lang="bash">
 +
make install
 +
</syntaxhighlight>
 +
 
  
 
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]]
 
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]]

Latest revision as of 12:34, 15 October 2012

[edit] 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.

[edit] 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.

[edit] 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,770 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