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

Jump to: navigation, search
(Getting the source code)
(Getting the source code)
Line 20: Line 20:
 
And check out the application there:
 
And check out the application there:
 
  git clone kde:parley
 
  git clone kde:parley
 
 
<syntaxhighlight lang="cpp-qt">
 
foo bar
 
</syntaxhighlight>
 
  
 
Let's create a script that you can source to set up your development environment.
 
Let's create a script that you can source to set up your development environment.
  
  PARLEY_PATH=/home/frederik/devel/install
+
  PARLEY_PATH=~/devel/install
 
  export PATH=$PARLEY_PATH/bin:$PATH
 
  export PATH=$PARLEY_PATH/bin:$PATH
  export LD_LIBRARY_PATH=$PARLEY_PATH/lib/kde4:$PARLEY_PATH/lib64:/home/frederik/dev/qt/qt-4/lib
+
  export LD_LIBRARY_PATH=$PARLEY_PATH/lib/kde4:$LD_LIBRARY_PATH
 
  export KDEDIR=$PARLEY_PATH
 
  export KDEDIR=$PARLEY_PATH
 
  export KDEDIRS=$PARLEY_PATH
 
  export KDEDIRS=$PARLEY_PATH
  export QT_PLUGIN_PATH=$KDEDIR/lib/kde4:$KDEDIR/lib64
+
   
 
  kbuildsycoca4
 
  kbuildsycoca4
  
Line 47: Line 42:
 
  mkdir -p ~/devel/build/parley
 
  mkdir -p ~/devel/build/parley
 
  cd ~/devel/build/parley
 
  cd ~/devel/build/parley
  cmake ../../src/parley -DCMAKE_INSTALL_PREFIX=$PARLEY_PATH
+
  cmake ../../src/parley -DCMAKE_INSTALL_PREFIX=$PARLEY_PATH -DCMAKE_BUILD_TYPE=debugfull
  
 
Make sure that <tt>cmake</tt> tells you that everything is all right at this point.
 
Make sure that <tt>cmake</tt> tells you that everything is all right at this point.
Line 53: Line 48:
 
  make
 
  make
 
(Or to make use of all your cpu cores make -j8 for 8 cores...)
 
(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 ==
 +
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.)

Revision as of 23:17, 8 May 2012

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.

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 it's 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.

PARLEY_PATH=~/devel/install
export PATH=$PARLEY_PATH/bin:$PATH
export LD_LIBRARY_PATH=$PARLEY_PATH/lib/kde4:$LD_LIBRARY_PATH
export KDEDIR=$PARLEY_PATH
export KDEDIRS=$PARLEY_PATH

kbuildsycoca4

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

source parley-devel-env

If you run

export

now it should show you the variables that get set in the script.

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 ../../src/parley -DCMAKE_INSTALL_PREFIX=$PARLEY_PATH -DCMAKE_BUILD_TYPE=debugfull

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.

Figuring out Dependencies

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.)


KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal