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.
1.Dependencies
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
1.2.Qt
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/
/home/
/home/
/home/
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
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:
https://phabricator.kde.org/diffusion/KRITA/ (for looking at code)
https://github.com/KDE/krita (https://github.com/KDE/krita.git)(Gihub mirror)
git://anongit.kde.org/krita (fesh)(The normal way of getting krita)
ssh://git@git.kde.org/krita (push)(If you are a developer you can upload your changes here)
Run this:
cd ~/Mybuilds/krita
git clone git://anongit.kde.org/krita.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 https://github.com/VcDevel/Vc)
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 https://github.com/VcDevel/Vc.git
cd Vc ; mkdir build ; cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/Vc -DBUILD_TESTING=OFF ..
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
cmake -DCMAKE_INSTALL_PREFIX="$HOME/Mybuilds/krita/inst" -DWITH_GMIC=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DPRODUCTSET=ALL -DPACKAGERS_BUILD=ON -DBUILD_TESTING=OFF -DKDE4_BUILD_TESTS=OFF ../src 2>&1 | tee cmake_output.log
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)
Run:
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
PATH=$HOME/Mybuilds/krita/inst/bin:$HOME/Mybuilds/krita/inst/etc:$HOME/Mybuilds/krita/inst/lib:$HOME/Mybuilds/krita/inst/share:$PATH
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
cd ~/Mybuilds/krita/build
cmake -DCMAKE_INSTALL_PREFIX="$HOME/Mybuilds/krita/build/inst" -DWITH_GMIC=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DPRODUCTSET=ALL -DPACKAGERS_BUILD=ON -DBUILD_TESTING=OFF -DKDE4_BUILD_TESTS=OFF ../src 2>&1 | tee cmake_output.log
make -j4
make install -j4
5.Rescuing
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
cmake -DCMAKE_INSTALL_PREFIX="$HOME/Mybuilds/krita/build/inst" -DWITH_GMIC=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DPRODUCTSET=ALL -DPACKAGERS_BUILD=ON -DBUILD_TESTING=OFF -DKDE4_BUILD_TESTS=OFF ../src 2>&1 | tee cmake_output.log
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
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: https://wiki.qt.io/Building_Qt_5_from_Git
Qt Creator: https://wiki.qt.io/Building_Qt_Creator_from_Git
Qt Documentation: http://wiki.qt.io/Building_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://code.qt.io/qt/qt5.git
cd qt5
git checkout 5.6.1
./init-repository
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
PATH=$HOME/Mybuilds/qt5/qtbase/lib/cmake:$HOME/Mybuilds/qt5/qtbase/bin:$PATH
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 https://code.qt.io/qt-creator/qt-creator.git
mkdir -p qt-creator-build
6.2.2.Configuring and building
Run this:
cd ~/Mybuilds/qt-creator-build
qmake -r ../qt-creator/qtcreator.pro
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
PATH=$HOME/Mybuilds/qt-creator-build/bin:$HOME/Mybuilds/qt-creator-build/lib:$HOME/Mybuilds/qt-creator-build/libexec:$HOME/Mybuilds/qt-creator-build/share:$PATH
And run the following to apply changes:
source ~/.bashrc
Congratulations, now you have the full Qt install.
Changelog:
20160614 - Did some cleanup and added documentation build for Qt
20160615 - Made some content rearrangements/corrections and added Krita code sources