Difference between revisions of "Development/Tutorials/Building An Existing Application"

Jump to: navigation, search
(Created page with "== Introduction == This tutorial aims to make it easy to get the source code of an application, build and install it in your home directory without interfering with your system. ...")
 
m (Getting the source code: rm wrong apostrophe)
 
(15 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
== Introduction ==
 
== Introduction ==
 
This tutorial aims to make it easy to get the source code of an application, build and install it in your home directory without interfering with your system.
 
This tutorial aims to make it easy to get the source code of an application, build and install it in your home directory without interfering with your system.
 +
 +
Note that this approach works for applications but most likely not for components that are deep in the system such as kdelibs themselves.
 +
 +
The setup is such that all development happens inside one directory inside your home directory and all settings also get written there. As example we use <tt>~/devel</tt>.
  
 
== Getting the source code ==
 
== Getting the source code ==
Line 9: Line 13:
 
You should also configure your git user name and email as mentioned on the git configuration page.
 
You should also configure your git user name and email as mentioned on the git configuration page.
  
If you don't know the right name, check out [http://projects.kde.org projects.kde.org] to find the right project name.
+
If you don't know the project name of the application you want to build, check out [http://projects.kde.org projects.kde.org] to find it.
  
Let's assume you want to build Parley from KDE Education and found that it's project name is simply <tt>parley</tt>.
+
Let's assume you want to build Parley from KDE Education and found that its project name is simply <tt>parley</tt>. Most project names are actually that simple.
  
 
Once you have the project name, create a directory which you will use for development. We'll use <tt>/home/username/devel/src</tt> for our source code.
 
Once you have the project name, create a directory which you will use for development. We'll use <tt>/home/username/devel/src</tt> for our source code.
Line 21: Line 25:
 
  git clone kde:parley
 
  git clone kde:parley
  
 +
Let's create a script that you can source to set up your development environment.
 +
If you want to understand more about this script, head over to [[Getting_Started/Build/Environment|Getting Started/Build/Environment]].
  
<syntaxhighlight lang="cpp-qt">
+
KDE_DEVELOPMENT_PATH=~/devel/install
foo bar
+
export PATH=$KDE_DEVELOPMENT_PATH/bin:$PATH
</syntaxhighlight>
+
export LD_LIBRARY_PATH=$KDE_DEVELOPMENT_PATH/lib/kde4:$LD_LIBRARY_PATH
 +
export KDEDIR=$KDE_DEVELOPMENT_PATH
 +
export KDEDIRS=$KDE_DEVELOPMENT_PATH
 +
export KDEHOME=~/devel/kdehome # Configuration settings end up here
 +
export KDETMP=/tmp/kde-git-$USER
 +
export KDEVARTMP=/var/tmp/kde-git-$USER
 +
export CMAKE_PREFIX_PATH=$KDEDIR:$CMAKE_PREFIX_PATH
 +
export CMAKE_LIBRARY_PATH=$KDEDIR/lib:$CMAKE_LIBRARY_PATH
 +
export CMAKE_INCLUDE_PATH=$KDEDIR/include:$CMAKE_INCLUDE_PATH
 +
mkdir -p $KDETMP
 +
mkdir -p $KDEVARTMP
 +
kbuildsycoca4
 +
 
 +
Call it for example kde-devel-env and source it:
 +
source kde-devel-env
 +
 
 +
Now we want to have a build directory at the same level as the source directory to keep everything neat.
 +
From there we run cmake to create makefiles that allow us to run make to build the application.
 +
mkdir -p ~/devel/build/parley
 +
cd ~/devel/build/parley
 +
cmake -DCMAKE_INSTALL_PREFIX=$KDE_DEVELOPMENT_PATH -DCMAKE_BUILD_TYPE=debugfull ../../src/parley
 +
 
 +
Make sure that <tt>cmake</tt> tells you that everything is all right at this point.
 +
If all went well, you're good to go, run make:
 +
make
 +
(Or to make use of all your cpu cores make -j8 for 8 cores...)
 +
And if make finished, install.
 +
make install
 +
 
 +
Now you should have the application actually installed in /home/username/devel/install.
 +
To let kde applications find all their plugins it might be necessary to run kbuildsycoca4 again at this time.
 +
 
 +
== Figuring out Dependencies ==
 +
Running cmake should give you a good idea what's missing. But sometimes it's easiest to just take advantage of what your distribution has to offer.
 +
 
 +
Most of the time your distribution will provide you with most dependencies for your project.
 +
For Debian/Kubuntu run:
 +
apt-get build-dep parley
 +
On openSuse:
 +
zypper source-install parley
 +
(Fetches the source package and installs dependencies. You can then safely remove the source package.)
 +
 
 +
 
 +
== Library dependencies ==
 +
If you find that you later want to also change libkdeedu which is used by Parley, you are good to go, since the setup above is so that libraries from your build will be found.
 +
cd ~/devel/src
 +
git clone kde:libkdeedu
 +
cd ../build/
 +
mkdir libkdeedu
 +
cd libkdeedu/
 +
cmake -DCMAKE_INSTALL_PREFIX=$KDE_DEVELOPMENT_PATH ../../src/libkdeedu/
 +
make
 +
make install

Latest revision as of 04:00, 15 January 2013

Contents

[edit] Introduction

This tutorial aims to make it easy to get the source code of an application, build and install it in your home directory without interfering with your system.

Note that this approach works for applications but most likely not for components that are deep in the system such as kdelibs themselves.

The setup is such that all development happens inside one directory inside your home directory and all settings also get written there. As example we use ~/devel.

[edit] Getting the source code

Make sure to set up git URL renaming properly, so that you can use commands below.

Git Configuration and URL Renaming

You should also configure your git user name and email as mentioned on the git configuration page.

If you don't know the project name of the application you want to build, check out projects.kde.org to find it.

Let's assume you want to build Parley from KDE Education and found that its project name is simply parley. Most project names are actually that simple.

Once you have the project name, create a directory which you will use for development. We'll use /home/username/devel/src for our source code.

mkdir -p ~/devel/src
cd ~/devel/src

And check out the application there:

git clone kde:parley

Let's create a script that you can source to set up your development environment. If you want to understand more about this script, head over to Getting Started/Build/Environment.

KDE_DEVELOPMENT_PATH=~/devel/install
export PATH=$KDE_DEVELOPMENT_PATH/bin:$PATH
export LD_LIBRARY_PATH=$KDE_DEVELOPMENT_PATH/lib/kde4:$LD_LIBRARY_PATH
export KDEDIR=$KDE_DEVELOPMENT_PATH
export KDEDIRS=$KDE_DEVELOPMENT_PATH
export KDEHOME=~/devel/kdehome # Configuration settings end up here
export KDETMP=/tmp/kde-git-$USER
export KDEVARTMP=/var/tmp/kde-git-$USER
export CMAKE_PREFIX_PATH=$KDEDIR:$CMAKE_PREFIX_PATH
export CMAKE_LIBRARY_PATH=$KDEDIR/lib:$CMAKE_LIBRARY_PATH
export CMAKE_INCLUDE_PATH=$KDEDIR/include:$CMAKE_INCLUDE_PATH
mkdir -p $KDETMP
mkdir -p $KDEVARTMP
kbuildsycoca4

Call it for example kde-devel-env and source it:

source kde-devel-env

Now we want to have a build directory at the same level as the source directory to keep everything neat. From there we run cmake to create makefiles that allow us to run make to build the application.

mkdir -p ~/devel/build/parley
cd ~/devel/build/parley
cmake -DCMAKE_INSTALL_PREFIX=$KDE_DEVELOPMENT_PATH -DCMAKE_BUILD_TYPE=debugfull ../../src/parley

Make sure that cmake tells you that everything is all right at this point. If all went well, you're good to go, run make:

make

(Or to make use of all your cpu cores make -j8 for 8 cores...) And if make finished, install.

make install

Now you should have the application actually installed in /home/username/devel/install. To let kde applications find all their plugins it might be necessary to run kbuildsycoca4 again at this time.

[edit] Figuring out Dependencies

Running cmake should give you a good idea what's missing. But sometimes it's easiest to just take advantage of what your distribution has to offer.

Most of the time your distribution will provide you with most dependencies for your project. For Debian/Kubuntu run:

apt-get build-dep parley

On openSuse:

zypper source-install parley

(Fetches the source package and installs dependencies. You can then safely remove the source package.)


[edit] Library dependencies

If you find that you later want to also change libkdeedu which is used by Parley, you are good to go, since the setup above is so that libraries from your build will be found.

cd ~/devel/src
git clone kde:libkdeedu
cd ../build/
mkdir libkdeedu
cd libkdeedu/
cmake -DCMAKE_INSTALL_PREFIX=$KDE_DEVELOPMENT_PATH ../../src/libkdeedu/
make 
make install

This page was last modified on 15 January 2013, at 04:00. This page has been accessed 8,019 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