Sunday, June 12, 2016

Building Krita 3.0 from sources on Linux Mint 18

This guide focuses on getting Krita build on a fresh Linux Mint 18 setup, is based on David Revoy's "Building Krita 3.0 on Linux for cats", which helped me a lot to do my first build.


Before you start, you need to install a few things if you have a "Fresh Mint" setup :3

NOTE: Make sure you enable source code repositories first before you start or you will run into errors:

Go to: Software Manager Edit->Software Sources->Official repositories->Source code->(Check)Enable source code repositories

1.1.General stuff

You can't start without git, g++ and cmake, also included ffmpeg because it will be needed to export video for animation.

Run this:
sudo apt-get update
sudo apt-get install git
sudo apt-get install g++

sudo apt-get install cmake
sudo apt-get install cmake-extras extra-cmake-modules

sudo apt-get install ffmpeg chromium-codecs-ffmpeg ffmpegthumbs libavresample-dev libpostproc-dev libxine2-ffmpeg libavutil-dev libswresample-dev

sudo apt-get install flex bison gperf libicu-dev libxslt-dev ruby

You need Qt to build Krita, if you download the installer, make sure you select everything for that version, the normal install is missing some modules that Krita needs. Get Qt here.

At the bottom I'm including a section to build Qt from sources (Section 5) if you are adventurous, I builded it from sources myself because I wanted the latest 5.6.1 version, and also because I'm a geek :)

1.3.Qt dependencies
If you decide to build Qt from sources you should install the following dependencies (it won't hurt if you install them anyway, didn't test if some of this is needed to build Krita also):

Run this:
sudo apt-get build-dep qt5-default

sudo apt install yaz-icu libghc-text-icu-prof libghc-text-icu-dev icu-devtools python-pyicu libxcb-xinerama0-dev

sudo apt-get install libssl-dev libxcursor-dev libxcomposite-dev libxdamage-dev libxrandr-dev libfontconfig1-dev libcap-dev libxtst-dev libpulse-dev libudev-dev libpci-dev libnss3-dev libasound2-dev libxss-dev libegl1-mesa-dev

sudo apt-get install libasound2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev

1.4.Krita dependencies
Run this:
sudo apt-get build-dep krita

sudo apt-get install libeigen3-dev libxi-dev phonon-backend-gstreamer kdelibs5-dev libboost-dev libboost-all-dev exiv2

sudo apt-get install libcurl4-openssl-dev
sudo apt-get install libcurl4-nss-dev
sudo apt-get install libcurl4-gnutls-dev

sudo apt-get install libgrss0 libgrss-dev libpoppler-qt5-1 libpoppler-qt5-dev libraw-dev

sudo apt-get install kdelibs5-data kdelibs5-plugins
sudo apt-get install libkf5*-dev

2.Setup directories

I differ a little from David's guide because I'm building more stuff and its best to have all in one place.

2.1.The directory structure

The top directory of the setup will be "Mybuilds", this is where all the sources and builds will be.

Create all the directories:

For Krita:
/home/{your-user-name}/Mybuilds/krita/build   (It's where all the intermediate stuff will be when building)

/home/{your-user-name}/Mybuilds/krita/extras   (Place for additional modules that need to be build by source)

/home/{your-user-name}/Mybuilds/krita/inst   (It's where the Krita binaries will be placed)

/home/{your-user-name}/Mybuilds/krita/src   (All Krita source code will be here)

For Qt(only if you are building from sources):
/home/{your-user-name}/Mybuilds/qt5   (Where Qt base components will be)

/home/{your-user-name}/Mybuilds/qt-creator   (Where Qt Creator IDE will be installed)

/home/{your-user-name}/Mybuilds/qt-creator-build   (This is needed to properly build Qt Creator)

Note : understand as your user name on this documentation ( Ex :  /home/deevad/krita/src )

2.2.Create all the directories

For Krita:
mkdir -p  ~/Mybuilds/krita/build
mkdir -p  ~/Mybuilds/krita/extras
mkdir -p  ~/Mybuilds/krita/inst
mkdir -p  ~/Mybuilds/krita/src

For Qt(Only if you are building it from sources):
mkdir -p  ~/Mybuilds/qt5
mkdir -p  ~/Mybuilds/qt-creator
mkdir -p  ~/Mybuilds/qt-creator-build

3.Building Krita from sources

Linux Mint 18 comes with everything you need to build Krita without problem, all libraries are up to date, also using recent KDE 5, you just have to install it.

3.1.The directories

As I mentioned at the beginning, this are the directories we are going to create  for Krita if you haven't created them already:

Run this:
mkdir -p  ~/Mybuilds/krita/build   (It's where all the intermediate stuff will be when building)
mkdir -p  ~/Mybuilds/krita/extras   (Place for additional modules that need to be build by source)
mkdir -p  ~/Mybuilds/krita/inst   (It's where the Krita binaries will be placed)
mkdir -p  ~/Mybuilds/krita/src   (All Krita source code will be here)

3.2.Getting Krita sources

There are 4 places places were you can get the krita code: (for looking at code) ( mirror)
git:// (fesh)(The normal way of getting krita)
ssh:// (push)(If you are a developer you can upload your changes here)

Run this:
cd ~/Mybuilds/krita
git clone git:// src

After this all your source files will be downloaded to ~/Mybuilds/krita/src

3.3.Installing dependencies

Besides the dependecies listed at the top of this guide for Krita you will need to build Vc, since for some reason the pre build for Linux Mint was not being detected by cmake.

3.3.1.Building Vc from sources

This is needed for vectors or something.... the prebuild version doesn't contain the headers Krita needs so we need to build from sources. (Vc web

Make sure you remove the existing library (in case it's already installed) before you continue:

sudo apt-get remove vc-dev

Download, configure and build Vc:
Run this:
cd ~/Mybuilds/krita/extras
git clone
cd Vc ; mkdir build ; cd build

make -j4
sudo make install

This thing gets installed in /opt/Vc so you're good to go.

3.4.Configure sources

Run this:
cd ~/Mybuilds/krita/build

Sometimes you run into unexpected problems, and you need to debug but the problem "outscrolls" your terminal, so I'm logging the output to cmake_output.log if you need to debug an issue.

So after this, a bunch of files get created in ~/Mybuilds/krita/build and you are ready to start building Krita.

3.5.Building Krita

NOTE: Before we start, adding the "-jN" to make means that will use more than one core in your processor, I recommend this because it will take less time. If you don't know the number of cores in your machine, you can use the following command to get them:

cat /proc/cpuinfo | grep processor | wc -l

Mine is 4, so will use -j4:
make -j4

3.6.Installing Krita (At last)


make install -j4

This also takes a while but after it finishes all your binaries should be in  ~/Mybuilds/krita/inst, now the only thing left to do is to make Krita visible to the system.

Congratulations!, you have successfully build Krita from sources.

3.7.Making Krita visible to the system

Edit "~/.bashrc" again and add the following lines:

# For Krita setup

3.8.First run

Finally you can open a terminal and run krita.

$ krita

3.9.Doing cleanup (optional)

It's a good practice to do housekeeping and clear any leftover packages running this commands, it's not necessary but like to do it:

sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get clean
sudo apt-get purge

4.Updating your Krita to the latest version

You've heard of a new feature developed, or you read about an annoying bug fixed, and want to update ?

Fine, call git again. This time it will only append to your source folder the missing code lines. Not downloading the whole source pack.

4.1.Updating source repository

Run this:
cd ~/Mybuilds/krita/src/
git pull

4.2.Configure and building

Run this:
cd ~/Mybuilds/krita/build

make -j4
make install -j4


Recent development version might break, and sometime be unusable. Experimental changes are made daily.

It might affect your productivity if you don't know how to 'go back in time' ( ex: your favorite brush doesn't work anymore ).

But If you know how to do it, no issue can really affect you, because you know how to come back to a previous state.

5.1.Reverting to a working version

To travel the source in time we need to read the timeline history. The Terminal tool for it is git log

Run this:
cd ~/Mybuilds/krita/src/
git log

With git log , you can consult all the last changes to the code, named 'commit' . What interest us is the long identification number ( ex: cca5819b19e0da3434192c5b352285b987a48796 ). You can scroll git log , copy the ID number then quit ( letter Q on keyboard ). Then time-travel your source directory

Run this:
git checkout cca5819b19e0da3434192c5b352285b987a48796

Now, configure, compile, and you'll be again in a safe place. Note that I advice the packages gitg or gitk to have a graphic user interface to visualise git history. Also an online version exist here.

5.2.Configure and building

Run this:
cd ~/Mybuilds/krita/build

make -j4
make install -j4

5.3.Returning to master branch

To update again to the actual and fresh from a minute ago source-code named master , simply ask git to come back to it with git checkout  then  pull to update

Run this:
git checkout master
git pull

6.Building Qt from sources

To have a full Qt setup, you need to build 3 things, the Qt components, the IDE (Qt Creator), and the documentation.

For more information on Qt setup go to:
Qt base:
Qt Creator:
Qt Documentation:

6.1. Building Qt base components from sources

6.1.1.Download sources and prepare the repository

Run this:
cd ~/Mybuilds
git clone git://
cd qt5
git checkout 5.6.1

6.1.2.Configure and building

Run this:
./configure -developer-build -opensource -no-gtkstyle -confirm-license

make -j4

Go grab snack or a cup of coffee, because its going to take a while, and if everything goes well you will end up with all your binaries inside ~/Mybuilds/qt5/qtbase/bin

6.1.3.Making your Qt setup visible to the system

Now that we have our bins, we need to tell Mint where to find them, there are several ways to do this but I found this one the easiest:

Edit the hidden file in your home "~/.bashrc" and add this lines at the bottom:

# For Qt base

Now run this for it to pick up the changes:
source ~/.bashrc

You now have Qt base installed, now we need to install the IDE (Qt Creator)

6.2.Building Qt Creator from sources

You should have everything you need by now to build this.

6.2.1.Download Qt Creator sources

Run this:
cd ~/Mybuilds
git clone --recursive
mkdir -p qt-creator-build

6.2.2.Configuring and building

Run this:
cd ~/Mybuilds/qt-creator-build
qmake -r ../qt-creator/
make -j4

There shouldn't be a problem with this one, it's just takes time. After this the binaries for Qt Creator should be in ~/Mybuilds/qt-creator-build/bin

6.2.3.Making Qt Creator visible to the system

Like Qt base, we edit "~/.bashrc" file and add at the bottom the following lines:

# For Qt Creator

And run the following to apply changes:
source ~/.bashrc

Congratulations, now you have the full Qt install.

20160614 - Did some cleanup and added documentation build for Qt
20160615 - Made some content rearrangements/corrections and added Krita code sources


Unknown said...

Tank you for making this tutorial!! Im so greatfull!:D

Im new to linux so this really helps me alot. The only thing im a bit worried about is that when i try to use the terminal i tend to run into errors.. and if i do that i won't really know what to do:$

But i mean if it messes up halfway through can i just close the terminal amd delete the files and my computer will be "untouched"?

Ruakuu said...

@unknown, if you follow the same directory path convention, then everything is done inside MyBuilds folder, and nothing gets out of there, if you are working on krita only then everything stays inside there if you get erros, its just a matter of checking the logs and correct, or going back on git to a different commit that works and rebuild again. Or if you want to try from scratch you can safely delete the krita and recreate the krita folder, hope this helps.