Difference between revisions of "Calligra/Building"

Line 322: Line 322:
on the CMake command line.
on the CMake command line.
{{note|The set of included plugins and extra tools may differ between product sets. Consult the product set definitions in the <tt>cmake/productsets</tt> directory of the Calligra sources for detailed information about what is included in each product set.}}
{{note|The set of included plugins, import/export filters and extra tools may differ between product sets. Consult the product set definitions in the <tt>cmake/productsets</tt> directory of the Calligra sources for detailed information about what is included in each product set.}}
== Fine-grained Selection ==
== Fine-grained Selection ==

Revision as of 12:24, 24 March 2013

These instructions are for Unix and similar operating systems. For Windows, see the building Calligra on Windows page.


First, to avoid conflicting copies of software, make sure you do not have other copy of Calligra or KOffice either installed through the package manager of your distribution or installed in any other way. Calligra and KOffice are mutually exclusive!

Follow this guide as an ordinary user. Do not login as root!

Recommended Setup

Here is recommendation of a directory structure:

source code
directory that Calligra will be built in
directory that Calligra will be installed in

The build directory is needed because you cannot (or should not) build Calligra inside the source directory; the source and build directory have to be separated.

Create these directories with:

mkdir -p ~/kde4/src; mkdir -p ~/kde4/build; mkdir -p ~/kde4/inst

Advantages of this setup:

  • It is possible to have different builds (e.g. with different options out of the same source code)
  • David Faure's scripts can be used to make development easier. With those scripts "make" can be typed in the source directory and building will happen in the right (build) directory automatically.

Also, check the Techbase instructions on setting up a build environment. That contains some useful scripts and functions.

Getting the Source Code

There are two most useful options:

  1. Get the source code for the latest stable version.
  2. Get the source code for the current development version. Needed to test, check and give feedback about features that is in development and have not been released yet.

If unsure pick the stable version.

Latest Stable Version

The latest stable Calligra version is 3.1.0.

It can be downloaded as single archive file from http://download.kde.org/stable/calligra-latest/calligra-3.1.0.tar.bz2

If you prefer, stable versions are also available on the git repository too. To get stable version x.y from git, first clone the repository (git clone kde:calligra) and switch to calligra/x.y branch (that's the notation). Full procedure of cloning is available in the Get the source code for the development version section below.

The branch for the latest stable version is calligra/3.1 and it contains code updates for current minor stable release 3.1.0 plus updates for the next minor stable (if there are any).

Development Version

The latest development version of Calligra is 3.1.0 Alpha; developers always refer to it as to Master. Applications from Master should always compile and be reasonably stable. Calligra developers never place experimental features there. Once tested and released, Master becomes the new current stable version 3.1.

TODO: Here we should explain local branches, staging and always-release-ready Master, if we have that setup.

  • Option 1: directly from git

To retrieve the source code from Git you have to use the following setup:

Add the following text to your ~/.gitconfig:

[url "git://anongit.kde.org/"]
    insteadOf = kde:
[url "ssh://[email protected]/"]
    pushInsteadOf = kde:

Then execute

$ git clone kde:calligra

By using the kde: prefix, read access will automatically happen over Git, and authenticated SSH is only required for pushes.

Note that pushing your changes will only work if you have a KDE developer identity (https://identity.kde.org/register.php).

The $HOME/kde4/src/calligra directory will be created regardless of the way how the source code has been downloaded.

  • Option 2: download a repository tarball

Go to https://projects.kde.org/projects/calligra/repository. Press the "Tarball" button. Copy the url text and paste it on your command line. It will look like:

wget -c http://anongit.kde.org/calligra/calligra-latest.tar.gz

Unpack and cd into directory, then run

$ ./initrepo.sh

From now on, you can run

$ git pull

to update, or

$ git rebase origin/master

if you have local changes

  • Option 3: if beta or rc version was released, the source code for the latest beta can be found on KDE's ftp calligra-latest. Uncompress the code so that $HOME/kde4/src/calligra is created.

Working with Multiple Versions

You will often want to have more than one build environment in parallel, for example if you want to work on both stable and unstable branches at the same time or several feature branches.

Recommended way is to use git-new-workdir tool. The solution is based on a single git repository clone multiplied to many separate source directories for each branch you wish to use, all without performing full clone (what consumes disk space and requires fetching each clone separately). It is explained in the Techbase article Multiple Work Branches and you can find the script there.

Example commands to have code for both Calligra 3.1.x and master versions:

To get the master into $HOME/kde4/src/calligra:

$ git clone kde:calligra

Then, to get the Calligra 3.1.x into $HOME/kde4/src/calligra-3.1:

$ git-new-workdir $HOME/kde4/src/calligra $HOME/kde4/src/calligra-3.1 calligra/3.1

(which means git-new-workdir <original clone's directory> <new source directory> <branch name>)

Build Requirements

This section provides information about hard (required) and optional software packages needed to build the Calligra software.

Required Dependencies

A note for developers: to add (or remove) a hard dependency, an explanation of the reason, and possibly a discussion must be posted in advance on [email protected] The new dependency need to be packaged in the most widely used distributions (Debian, Fedora Core, OpenSuSE, (K)ubuntu). First try to make your new feature optional.

Following are the general must-have dependencies for Calligra (unless you really need to do otherwise, just install relevant binary packages):

  • Qt 4.7.0 or newer
  • kdelibs and kdelibs development files
    • the minimal requirement is currently 4.3.0, that or any later release packaged in your distribution is OK
    • On opensuse the development package is called libkde4-devel; on Ubuntu and Debian it is called kdelibs5-dev. (TODO: add info for other distributions)
    • Calligra should also build fine with either kdelibs from git repository (see techbase for an explanation on how to compile kdelibs from svn), needed for parts of Calligra build with the Mobile Frameworks Profile of the KDE platform (Calligra Words, Calligra Sheets, Calligra Stage, krita)
  • kdebase/runtime 4.3 or newer
  • cmake 2.6.2 or newer
  • lcms 2.4 or newer
  • libpng development package (libpng14-devel on opensuse, libpng-dev on Ubuntu/Debian)
    • development packages for other libraries may be needed; on ubuntu/Debian these can be installed using 'apt-get build-dep kdelibs5'

For Calligra Sheets:

  • libeigen 2.0

For Krita:

  • libeigen 2.0
  • libexiv2 >= 0.16

For Stage:

  • boost

For Kexi:

  • sqlite3 and sqlite3-devel packages (package names can differ on various distributions), version >= 3.7.10
  • icu, libicu and libicu-devel (unicode support)

Optional Dependencies

All optional dependencies are logged at the end of the cmake run, so it is easy to figure out what is missing. The buildsystem also reports what component will not be built because given missing dependency.

For users who want to use Krita it is also recommended to install the Vc library. It is optional, but makes the performance much higher.

Distribution Specific Instructions

Most distribution don't ship Calligra yet, so you may replace calligra it by koffice or koffice2 in those command lines.

Debian-based Distributions

On Debian-based distributions such as Debian, Ubuntu and Kubuntu, all the dependencies used for the packages can be installed by running:

sudo apt-get build-dep calligra


All the dependencies used for building Calligra can be installed by running:

zypper si -d calligra


All the dependencies used for building Calligra can be installed by running:

yum-builddep calligra

Arch Linux

All the dependencies used for building Calligra can be installed by running:

sudo pacman -S kdepimlibs eigen2 freetds kdegraphics-okular libgsf libwpd libwpg libwps libvisio pstoedit glew gsl cmake automoc4 boost libkdcraw libpqxx fftw opengtl lcms2


All the dependencies used for building Calligra can be installed by running:

sudo pacman -S kdelibs kdepimlibs eigen freetds kdegraphics-okular kdeedu-marble xbase libgsf libwpd libwpg libwps libvisio pstoedit glew gsl cmake automoc4 libspnav libqtgtl boost libkdcraw libpqxx fftw opengtl docbook-xsl create-resources lcms2 qrencode libdmtx

Build Calligra

It is not possible to build Calligra in the source directory. Set up your directories as described in the Recommended setup section above


mkdir -p $HOME/kde4/build/calligra
mkdir -p $HOME/kde4/inst
cd $HOME/kde4/build/calligra

There is a bug in Qt 4.8.0 and 4.8.1 which crashes the textshape quite heavily. The bug is fixed in Qt 4.8.2. There is a patch avaliable for Qt and most distributions that ship calligra have included the patch in their QT. See README.PACKAGERS for more information on the topic. If you have applied the patch here is the cmake command you need to use so all gets build:

cmake -DCMAKE_INSTALL_PREFIX=$HOME/kde4/inst $HOME/kde4/src/calligra \

Otherwise type the command without the IHAVEPATCHEDQT flag:

cmake -DCMAKE_INSTALL_PREFIX=$HOME/kde4/inst $HOME/kde4/src/calligra \

cmakekde tool can be used as explained on the build instructions for KDE4.

Then type:


Note that on dual-core machines compilation can be greatly speed up with the -j parameter of the make program, for example for dual-core:

make -j3

and for quad-core:

make -j5

n cores -> -jn+1

Then type this command to install the software:

make install

Debugging options. The default debug setting is RelWithDebInfo which is suitable for most developers. If you are debugging an application and cannot trace the codew, you can set CMAKE_BUILD_TYPE to "DebugFull" to get a slower Calligra but with even more verbose debugging (backtrace) information. For this replace -DCMAKE_BUILD_TYPE=RelWithDebInfo in the above cmake command with -DCMAKE_BUILD_TYPE=DebugFull. However, all Calligra applications will crash on closing with this option enabled.

If you are working on Krita, use the KritaDevs option always.

Please follow the Running Calligra Applications instructions before trying to run an application.

Updating and Rebuilding

If the source code has been cloned using Git, it is possible to update the source code with newly added changes and build again. Usually only changing parts will be built, so this operation would be faster than building the source code from scratch.


cd $HOME/kde4/src/calligra
git pull --rebase
cd $HOME/kde4/build/calligra
make install
make -j4 or make -j8 can be used instead of make to speedup the build on multicore machines

Building Selected Applications

Using Product Sets

By default, the build system tries to build all applications. The recommended way to change this is to specify a different product set by setting the PRODUCTSET CMake variable. The following table illustrates the available product sets.

Application Product Set
Active X X
Author X X X
Braindump X X
Flow X X X
Karbon X X X
Kexi X X X
Krita X X X X
Plan X X
Sheets X X X
Stage X X X
Words X X X

For example, to build the CREATIVE product set, pass


on the CMake command line.

The set of included plugins, import/export filters and extra tools may differ between product sets. Consult the product set definitions in the cmake/productsets directory of the Calligra sources for detailed information about what is included in each product set.

Fine-grained Selection

Advanced users and developers wishing to disable certain applications may do so by setting the corresponding BUILD_{application} variable to OFF. For example, to disable compilation of Krita and Karbon, you can pass

-DBUILD_krita=OFF -DBUILD_karbon=OFF

on the CMake command line. You can also do this using the ccmake tool included with CMake, which you may run after the initial CMake run but before you run make.

Many components should not be disabled using BUILD_{something}. Set these variables with caution!

Running Calligra Applications

There are two options to make the Calligra applications available for running.

Running from Command Line

If you have installed Calligra in a different prefix than KDElibs (which was recommended in this document), you have to set the following environment variables:

export KDEDIRS=/path/to/install:$KDEDIRS
export PATH=/path/to/install/bin:$PATH
export KDEHOME=/path/to/a/config/dir

And then you need to execute:


For example for the recommended directory structure:

export KDEDIRS=$HOME/kde4/inst:$KDEDIRS
export PATH=$HOME/kde4/inst/bin:$PATH
export KDEHOME=$HOME/kde4/.kde
It is important to set KDEHOME to a directory different of $HOME/.kde, and if the directory does not exist, it will be created automatically.

Running from Menus or Desktop Icons

Instead of using KDEDIRS, you can add these lines to $HOME/.kde/share/config/kdeglobals file using text editor:


And then you need to execute:


The advantage of this is that KDE will always look for the services where Calligra is installed. For example for the recommended directory structure:


Executing Unit Tests

To be able to execute unit tests, you need to explicitly enable them in the build configuration. To do so, set the KDE4_BUILD_TESTS variable to "ON", either by issuing the command in the build directory:

cd $HOME/kde4/build/calligra

Or you can run ccmake . in the buld directory and set KDE4_BUILD_TESTS to "on".

You can then run the test by executing:

make test

or individually in the tests directories.

It is recommended to execute

make install

before running tests.

CMake Build Options

When you enter your build directory, you can type "ccmake ." to see many build options, e.g. you can turn off compilation of apps you don't want - you can save time when compiling.

Here is list for Krita related options:

  • HAVE_MEMORY_LEAK_TRACKER [On/Off] - You can turn on compilation of the tool in krita which detects memory leak. If you want to help debug Krita memory usage, it is useful. Otherwise you just slow down your Krita.
  • HAVE_BACKTRACE_SUPPORT [On/Off] - It is related to the memory leak tool. If you activate, you will be able to see code path which leads to memory leak.


Possible Issues

If you get errors when running an application like:

krita(8565)/calligra (lib komain) KoPluginLoader::load: Loading plugin "Animation Tool" failed, 
"Cannot load library /home/michael/kde4/inst/lib/kde4/kpresentertoolanimation.so: 
(/home/michael/kde4/inst/lib/libkopageapp.so.7: undefined symbol:
_ZN28KoShapeContainerDefaultModel3addEP7KoShape)" ( 1 ) 

or crashes when starting an application, then you very likely have a version of Calligra installed through your package manager. As emphasized earlier in this document, you can only have one version of Calligra, and you should uninstall your packaged Calligra.

See also:

Note: if you want to build FreOffice using the Nokia Qt SDK, please check out the build instructions on techbase.

This page was last edited on 24 March 2013, at 12:24. Content is available under Creative Commons License SA 4.0 unless otherwise noted.