Krita/Emergebuild: Difference between revisions

From KDE Community Wiki
 
(43 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== What we are doing ==
== What is Craft? ==
* There are no binary releases of KDE Frameworks libraries for Windows. KDE Frameworks is required for Krita.  Therefore the only option is to build these libraries from source.
* KDE Frameworks depend on Qt and the Linux Standard Base, and Krita has other dependencies as well. Like KDE Frameworks, many of these dependencies have to be compiled too, so might as well do the entire set of libraries from source. That is what Craft does.
* To be flexible enough for this massive build task, Craft is written in Python.  Python is very easy to pick up.
* You will need approximately 20GB of free space for the whole thing.  Doing a separate debug/release build will require another 15GB, and the entire process must be repeated.  Fortunately, hard drives are cheap these days.
* If you do not have qualms with Windows Powershell, I recommend it over cmd.exe, since it has saner interactive features.  If you wish, you can get pretty good Bash-like keyboard shortcuts using [https://github.com/lzybkr/PSReadLine PSReadline].


* There are no binary releases of KDE Frameworks libraries. This means we will have to build KDE Frameworks from source.
== Preparing Craft ==
* 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.
* See here. https://community.kde.org/Craft
* Emerge is an automated way to do this written in Python to take care of this giant build task.
* Install Python 3.6
* General instructions for using Emerge can be found on the [https://techbase.kde.org/Getting_Started/Build/Windows/emerge Techbase Wiki].  
* Set up your .gitconfig so you can use <tt>kde:</tt> paths.
* You will need approximately 20GB of free space. Doing a release build will require another 20GB.  Luckily, hard drives are cheap these days.
* Install Microsoft Visual C++ 2015.  You can save some space by [http://blogs.msdn.com/b/vcblog/archive/2015/11/02/announcing-visual-c-build-tools-2015-standalone-c-tools-for-build-environments.aspx installing only the compiler without the IDE]. However, it is also possible to use the Visual Studio IDE to work with Krita's source if you wish. You will need to restart your computer after installing MSVC.
* 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 [https://github.com/lzybkr/PSReadLine PSReadline].
* Download Craft by running the script.
 
* Choose compiler = msvc2015 and architecture = x64.  
== General Emerge Instructions ==
* The instructions for each particular package are contained in the .\craft\portage subfolder.  You may expect to spend time fiddling with things here.
* The instructions generally follow https://community.kde.org/Calligra/Building_Calligra_on_Windows
* Use craft -v to give verbose output.  This can be helpful for diagnosing problems.
* 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.
* 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.
* 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, e.g. C:\kde_debug\ and C:\kde_release\, you can use symlinks on for C:\kde_XXX\emerge and C:\kde_XXX\download\ folders.  This 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.
* 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\craft and C:\kde_XXX\download\ folders.  That way, your build tweaks in the craft 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.
* A few other settings in kdesettings.ini are not necessary but will make the process nicer. This will build with 12 jobs (you can adjust that number to whatever is appropriate for your system), pop up a notification whenever a build process completes, alias the base directory to r:\, and skip building tests. (You can turn on testing for Krita itself later, but there is no need for you to build e.g. libjpeg tests.)
  EMERGE_OPTIONS = make.makeOptions=-j12
  CRAFT_OPTIONS = make.makeOptions=-j12
  EMERGE_USE_NOTIFY = Toaster
  CRAFT_USE_NOTIFY = Toaster
  EMERGE_USE_SHORT_PATH = True
  CRAFT_USE_SHORT_PATH = True
CRAFT_BUILDTESTS=False


== Build instructions ==
== Building Krita's Dependencies ==
=== Preparing for failure ===
Because we're building linux packages on MSVC and cloning from git master, we're begging for a list of build failures. What fails might change from day to day. Be prepared to make tweaks inside the source folders to get everything compiled. Feel free to stub things out if they seem pointless. Git repos are contained in Q:\, unzipped sources will be placed in r:\build\ working directories.  Often, to fix an error, you will want to run
craft --compile <target>
to try the compile command again without re-extracting the source. After it completes succesfully, run <tt>
craft --qmerge <target></tt> to install your patched version. See <tt>craft --help</tt> for more information.


=== Qt ===
=== Qt ===
* Step 1: <tt>emerge qt</tt>
* Step 1: <tt>craft qt</tt>
* Step 2: go get a cup of a coffee.
* Step 2: go get a cup of a coffee.


=== Krita dependencies ===
=== Krita dependencies ===
Many dependencies were relatively unproblematic:  
Many dependencies will be straightforward and unproblematic:  
  emerge pkg-config
  craft pkg-config
  emerge coreutils
  craft coreutils
  emerge eigen3
  craft eigen3
  emerge lcms2
  craft lcms2
  emerge exiv2
  craft exiv2
  emerge tiff
  craft tiff
  emerge lcms2
  craft libpng
  emerge exiv2
  craft lcms2
  emerge soprano
  craft libcurl
emerge gsl
  craft libwpd
emerge libcurl
  emerge libwpd
emerge ilmbase


A few were more difficult, although I pushed patches to upstream Emerge for most of them:
A few were can be difficult, although Craft contains patches for most of them.  You may need to manually disable tests for some libraries.
  emerge vc
  craft vc
  emerge eigen3
  craft ocio
emerge ocio
  craft breakpad
  emerge breakpad
  craft gsl
  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 <tt>portage/win32libs/boost/boost.py</tt> to turn off those dependencies helped building.
Boost worked
  emerge boost
  craft --fetch boost-headers
  craft --unpack boost-headers
craft --install boost-headers
craft --qmerge boost-headers
  craft 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


Finally there were some optional dependencies that can be put aside for the time being if they are not cooperating.  FFTW is straightforward to install by following the instructions from their website instead of using Craft.
craft FFTW
craft openexr
craft png2ico
craft librdf-src
craft shared-mime-info


=== Frameworks ===
=== Frameworks ===
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.
The goal here is to build as few as possible, because they can be rickety.  The situation seems pretty good as of KDE Frameworks 15.16, I encountered no build failures the last time I tried. The necessary frameworks are listed [[Krita | on this wiki]].
  emerge kdewin-lib
  craft kdewin-lib
  emerge karchive
  craft karchive
  emerge kconfig
  craft kconfig
  emerge kcoreaddons
  craft kcoreaddons
  emerge kguiaddons
  craft kguiaddons
  emerge ki18n
  craft ki18n
  emerge kitemmodels
  craft kitemmodels
  emerge kitemviews
  craft kitemviews
  emerge kwidgetsaddons
  craft kwidgetsaddons
  emerge kcompletion
  craft kcompletion
  emerge kio
  craft oxygen
craft breeze


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 finicky here and not all the flags may be necessary. If you can build without them, please note that here. Do not try to build the tests, such an endeavor would be dangerous for your mental health.


== Clone and build Krita ==
mkdir r:\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
cd r:\build\krita


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 r:\src\krita\ -DBUILD_TESTING=OFF -G"Ninja" -DCMAKE_INSTALL_PREFIX=r:\ -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_CXX_FLAGS="/Gm /MD /Zi" -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.1/bin/x64/rc.exe"


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"
The command <tt>-G"Ninja"</tt> specifies that you will be using the <tt>ninja</tt> command line build tool inside the build directory. Other options are <tt>"NMake Makefiles JOM"</tt>, to use the jom build tool, and <tt>-G"Visual Studio 14 2015"</tt> to generate .vcxproj project files, which can be opened in Visual Studio. You can make more than one build directory if you wish.


=== Boost problems ===
=== Boost problems ===


 
The CMake find_library call in Krita was also unable to locate Boost automatically.  I believe there is a way inside Craft to do this, but I have not pursued that.  Instead the following hack in the base CMakeLists.txt fixed things.  
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.  


  -add_definitions(-DBOOST_ALL_NO_LIB)
  -add_definitions(-DBOOST_ALL_NO_LIB)
Line 96: Line 105:
  +set(Boost_DEBUG "ON")
  +set(Boost_DEBUG "ON")


== gokde ==
FindBoost.cmake will look for dlls called things like boost_system-vc140-mt-1_55.dll but the boost dll's that I built were called boost_system-vc-mt-1_55, and that makes FindBoost FAIL!!!  If an error like that occurs, it can be fixed by renaming the dlls.
This was a little wrapper script I called <tt>gokde.ps1</tt> 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 <tt>add-pathvariable</tt> is from the PowerShell Community Extensions.
 
  D:\kde_qt5\emerge\kdeenv.ps1
== gokde.ps1 ==
This was a little wrapper script I called <tt>gokde.ps1</tt> to set up a few aliases for a Krita 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 <tt>add-pathvariable</tt> is from the [https://pscx.codeplex.com/ PowerShell Community Extensions].
  C:\kde\craft\kdeenv.ps1
  cd r:
  cd r:
  Set-Alias krita r:\bin\krita.exe
  Set-Alias krita r:\bin\krita.exe

Latest revision as of 05:31, 8 July 2017

What is Craft?

  • There are no binary releases of KDE Frameworks libraries for Windows. KDE Frameworks is required for Krita. Therefore the only option is to build these libraries from source.
  • KDE Frameworks depend on Qt and the Linux Standard Base, and Krita has other dependencies as well. Like KDE Frameworks, many of these dependencies have to be compiled too, so might as well do the entire set of libraries from source. That is what Craft does.
  • To be flexible enough for this massive build task, Craft is written in Python. Python is very easy to pick up.
  • You will need approximately 20GB of free space for the whole thing. Doing a separate debug/release build will require another 15GB, and the entire process must be repeated. Fortunately, hard drives are cheap these days.
  • If you do not have qualms with Windows Powershell, I recommend it over cmd.exe, since it has saner interactive features. If you wish, you can get pretty good Bash-like keyboard shortcuts using PSReadline.

Preparing Craft

  • See here. https://community.kde.org/Craft
  • Install Python 3.6
  • Set up your .gitconfig so you can use kde: paths.
  • Install Microsoft Visual C++ 2015. You can save some space by installing only the compiler without the IDE. However, it is also possible to use the Visual Studio IDE to work with Krita's source if you wish. You will need to restart your computer after installing MSVC.
  • Download Craft by running the script.
  • Choose compiler = msvc2015 and architecture = x64.
  • The instructions for each particular package are contained in the .\craft\portage subfolder. You may expect to spend time fiddling with things here.
  • Use craft -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\craft and C:\kde_XXX\download\ folders. That way, your build tweaks in the craft 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. This will build with 12 jobs (you can adjust that number to whatever is appropriate for your system), pop up a notification whenever a build process completes, alias the base directory to r:\, and skip building tests. (You can turn on testing for Krita itself later, but there is no need for you to build e.g. libjpeg tests.)
CRAFT_OPTIONS = make.makeOptions=-j12
CRAFT_USE_NOTIFY = Toaster
CRAFT_USE_SHORT_PATH = True
CRAFT_BUILDTESTS=False

Building Krita's Dependencies

Preparing for failure

Because we're building linux packages on MSVC and cloning from git master, we're begging for a list of build failures. What fails might change from day to day. Be prepared to make tweaks inside the source folders to get everything compiled. Feel free to stub things out if they seem pointless. Git repos are contained in Q:\, unzipped sources will be placed in r:\build\ working directories. Often, to fix an error, you will want to run

craft --compile <target>

to try the compile command again without re-extracting the source. After it completes succesfully, run

craft --qmerge <target> to install your patched version. See craft --help for more information.

Qt

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

Krita dependencies

Many dependencies will be straightforward and unproblematic:

craft pkg-config
craft coreutils
craft eigen3
craft lcms2
craft exiv2
craft tiff
craft libpng
craft lcms2
craft libcurl
craft libwpd

A few were can be difficult, although Craft contains patches for most of them. You may need to manually disable tests for some libraries.

craft vc
craft ocio
craft breakpad
craft gsl

Boost worked

craft --fetch boost-headers
craft --unpack boost-headers
craft --install boost-headers
craft --qmerge boost-headers
craft boost 


Finally there were some optional dependencies that can be put aside for the time being if they are not cooperating. FFTW is straightforward to install by following the instructions from their website instead of using Craft.

craft FFTW
craft openexr
craft png2ico
craft librdf-src
craft shared-mime-info

Frameworks

The goal here is to build as few as possible, because they can be rickety. The situation seems pretty good as of KDE Frameworks 15.16, I encountered no build failures the last time I tried. The necessary frameworks are listed on this wiki.

craft kdewin-lib
craft karchive
craft kconfig
craft kcoreaddons
craft kguiaddons
craft ki18n
craft kitemmodels
craft kitemviews
craft kwidgetsaddons
craft kcompletion
craft oxygen
craft breeze

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 finicky here and not all the flags may be necessary. If you can build without them, please note that here. Do not try to build the tests, such an endeavor would be dangerous for your mental health.

mkdir r:\build\krita
cd r:\build\krita
cmake r:\src\krita\ -DBUILD_TESTING=OFF -G"Ninja" -DCMAKE_INSTALL_PREFIX=r:\ -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_CXX_FLAGS="/Gm /MD /Zi" -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.1/bin/x64/rc.exe"

The command -G"Ninja" specifies that you will be using the ninja command line build tool inside the build directory. Other options are "NMake Makefiles JOM", to use the jom build tool, and -G"Visual Studio 14 2015" to generate .vcxproj project files, which can be opened in Visual Studio. You can make more than one build directory if you wish.

Boost problems

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

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

FindBoost.cmake will look for dlls called things like boost_system-vc140-mt-1_55.dll but the boost dll's that I built were called boost_system-vc-mt-1_55, and that makes FindBoost FAIL!!! If an error like that occurs, it can be fixed by renaming the dlls.

gokde.ps1

This was a little wrapper script I called gokde.ps1 to set up a few aliases for a Krita 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.

C:\kde\craft\kdeenv.ps1
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 {
   install-krita
   if ($LASTEXITCODE -eq 0) {
       krita
   }
}

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