< Krita
Revision as of 04:34, 30 October 2015 by Miabrahams (talk | contribs) (add emerge -v)


What is Emerge?

  • There are no binary releases of KDE Frameworks libraries. This means we will have to build KDE Frameworks from source.
  • KDE Frameworks require Qt and the Linux Standard Base. The latter must be compiled from source as well, so might as well do Qt while we're at it.
  • Emerge is an automated way to do this written in Python to take care of this giant build task.
  • General instructions for using Emerge can be found on the Techbase Wiki.
  • You will need approximately 20GB of free space. Doing a release build will require another 20GB. Luckily, hard drives are cheap these days.
  • If you do not mind Windows Powershell, I recommend using it instead of cmd.exe to minimize headaches. You can get pretty good Bash-like keyboard shortcuts with PSReadline.

Preparing Emerge

  • The instructions generally follow https://community.kde.org/Calligra/Building_Calligra_on_Windows
  • Install Microsoft Visual Studio 2015.
  • When configuring kdesettings.ini, choose KDECOMPILER = msvc2015 and Architecture = x64.
  • There is an option to use a preinstalled Qt instead of building it from source. I have not tried to do this before, it may be worth investigating. Qt 5 has recently become much better at not breaking MSVC builds, so it's mostly a matter of whether you have an extra hour to kill to compile Qt.
  • The instructions for each particular package are contained in the .\emerge\portage subfolder. This is where you should expect to spend time fiddling with things.
  • Use emerge -v to give verbose output. This can be helpful for diagnosing problems.
  • Choose carefully whether you want to do a debug build or release build. You have to do the whole thing from scratch if you want to have both. Windows does not allow linking debug and release libraries together.
  • If you do want to do both a debug and release build, e.g. C:\kde_debug\ and C:\kde_release\, you can use symlinks for the C:\kde_XXX\emerge and C:\kde_XXX\download\ folders. That way, your build tweaks in the emerge folder, and the massive amount of downloaded files and cloned git repositories, can be shared between the debug and release paths.
  • A few other settings in kdesettings.ini are not necessary but will make the process nicer.
EMERGE_OPTIONS = make.makeOptions=-j12

Building Krita's Dependencies


  • Step 1: emerge qt
  • Step 2: go get a cup of a coffee.

Krita dependencies

Many dependencies were relatively unproblematic:

emerge pkg-config
emerge coreutils
emerge eigen3
emerge lcms2
emerge exiv2
emerge tiff
emerge lcms2
emerge exiv2
emerge soprano
emerge gsl
emerge libcurl
emerge libwpd
emerge ilmbase

A few were more difficult, although I pushed patches to upstream Emerge for most of them:

emerge vc
emerge eigen3 
emerge ocio
emerge breakpad
emerge shared-mime-info

Boost was very challenging, and I could not figure out a reasonable upstream patch. Commenting out win32libs/boost-regex and win32libs/boost-iostreams from portage/win32libs/boost/boost.py to turn off those dependencies helped building.

emerge boost

Finally there were some dependencies that failed at first, but since they were optional, they can be put aside for the time being. FFTW can be installed by using the instructions from their website, instead of compiling from scratch as Emerge attempts to do.

emerge FFTW
emerge openexr
emerge png2ico
emerge librdf-src


The goal here is to build as few as possible, because they can be rickety. The necessary frameworks are listed in CMakeLists.txt in the Krita repo. Hopefully KIO will be removed soon, but it is still required at the moment.

emerge kdewin-lib
emerge karchive
emerge kconfig
emerge kcoreaddons
emerge kguiaddons
emerge ki18n
emerge kitemmodels
emerge kitemviews
emerge kwidgetsaddons
emerge kcompletion
emerge kio

I am not sure whether kdewin-lib includes KWindowSystem.

Build Krita

To configure Git and clone, follow these instructions, replacing "calligra" with "krita" in the name of the repo. https://community.kde.org/Calligra/Building_Calligra_on_Windows#Getting_the_source_code

Here is a cmake configure command which worked for me. I was very conservative here and you may not need so many flags. Do not try to build the tests, that would be dangerous for your mental health.

cmake ..\src\ -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX=r:\ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="/Gm /MD /Zi" -DCMAKE_MODULE_LINKER_FLAGS ="/machine:x64" -DCMAKE_EXE_LINKER_FLAGS="/machine:x64 /LTCG" -DCMAKE_SHARED_LINKER_FLAGS="/machine:x64" -DCMAKE_STATIC_LINKER_FLAGS="/machine:x64"-DCMAKE_RC_COMPILER="C:/Program Files (x86)/Windows Kits/8.0/bin/x64/rc.exe"

Boost problems

The CMake find_library call in Krita was also unable to locate Boost automatically. I believe there is a way inside Emerge to do this, but I have not pursued that. Instead the following hack in the base CMakeLists.txt fixed things.

+set(BOOST_INCLUDEDIR "r:/include")
+set(BOOST_LIBRARYDIR "r:/lib")
+set(BOOST_ROOT "r:")
+set(Boost_DEBUG "ON")


This was a little wrapper script I called gokde.ps1 used to get powershell in a good build environment. Feel free to use it as a guide with appropriate configurations. In particular, some of the environment variables may not be necessary on Windows. The cmdlet add-pathvariable is from the PowerShell Community Extensions.

cd r:
Set-Alias krita r:\bin\krita.exe
function global:install-krita {
   Stop-Process -processname Krita -ErrorAction SilentlyContinue
   ninja -C r:\build\calligra install

function global:build-krita {
   Stop-Process -processname Krita -ErrorAction SilentlyContinue
   ninja -C r:\build\calligra

function global:run-krita {
   if ($LASTEXITCODE -eq 0) {

Add-PathVariable r:\bin
Add-PathVariable r:\lib\krita
$env:XDG_DATA_HOME = "r:\share"
$env:XDG_CONFIG_HOME = "r:\config"
$env:KDEDIRS = "r:"
$env:KDEHOME = "r:\share\.kde"
$env:EDITOR = "notepad"

This page was last edited on 8 July 2017, at 05:31. Content is available under Creative Commons License SA 4.0 unless otherwise noted.