(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 | + | 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 | ||
| − | + | <syntaxhighlight lang="bash"> | |
| + | git clone git://anongit.kde.org/blinken | ||
| + | </syntaxhighlight> | ||
| − | |||
| − | + | 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 | + | <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> | ||
| − | |||
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. | ||
| − | + | <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. | ||
| − | + | <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]] | ||
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.
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.
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