Getting Started/Build/Example

    From KDE TechBase

    Example Build

    The following example recipe shows the full sequence of commands you would need to enter into the command line to build a typical KDE module:

    cd ~/kde-devel/src
    git clone git://
    mkdir ~/kde-devel/build/kdelibs
    cd ~/kde-devel/build/kdelibs
    cmake ~/kde-devel/src/kdelibs \
          -DCMAKE_BUILD_TYPE=debugfull \
    make install

    Let's break that recipe down and explain each step.


    First you navigate to a convenient folder to save the code in:

    cd ~/kde-devel/src

    Then request a copy of the code from the KDE source repository, in this example a copy of kdelibs from Git:

    git clone git://

    This may take some time to process. For Git you will see out output similar to:

    myuser@mybox:~/kde-devel/src> git clone git://
    Initialized empty Git repository in /home/myuser/kde-devel/src/kdelibs/.git/
    remote: Counting objects: 722134, done.
    remote: Compressing objects: 100% (138759/138759), done.
    remote: Total 722134 (delta 586243), reused 715797 (delta 580373)
    Receiving objects: 100% (722134/722134), 140.90 MiB | 706 KiB/s, done.
    Resolving deltas: 100% (586243/586243), done.

    This example will create a folder called ~/kde-devel/src/kdelibs containing all the kdelibs source code and all its history since KDE began.

    For an SVN checkout you will instead see output similar to:

    myuser@mybox:~/kde-devel/src> svn checkout svn://
    A    kdesdk/cmake
    A    kdesdk/cmake/samples
    A    kdesdk/cmake/samples/kpager
    A    kdesdk/cmake/samples/kpager/CMakeLists.txt
    A    kdesdk/COPYING.LIB
    U   kdesdk
    Checked out revision 1223739.


    First you create a convenient folder to build the code in:

    mkdir ~/kde-devel/build/kdelibs
    cd ~/kde-devel/build/kdelibs

    Next you need to run CMake to create the configuration files to be used in the build:

    cmake ~/kde-devel/src/kdelibs \
          -DCMAKE_BUILD_TYPE=debugfull \

    Various options can be passed to CMake to control how a project gets built, but these are the most common:

    • The first line tells CMake where it can find the source code that is to be built.
    • The second line tells CMake what type of build is required, in this example a debugfull build that will include useful information for when we are debugging any the software.
    • The third line tells CMake we also want the unit tests to be built.
    • The fourth line tells CMake where to install the software.