Krita/kf5build: Difference between revisions

From KDE Community Wiki
(Created page with "This page provides information about how to build and install Krita 3 from source using the kdesrc-build tool. This installation of Krita will be separate from any existing pl...")
 
(Update the path to build-include file)
 
(14 intermediate revisions by 3 users not shown)
Line 1: Line 1:
This page provides information about how to build and install Krita 3 from source using the kdesrc-build tool. This installation of Krita will be separate from any existing plasma installation, so that either of them can be run as desired.
This section provides information about 'building Qt5, Kf5 and Krita3.


= Preparation =
If you want to figure out bugs in Qt5 and Kf5, you need to build those, too, and need this guide. If you just want to build krita from git master, you should be able to install the kf5 and qt5 devel packages through your package manager and build krita in the usual way.
== Git remote prefix ==
 
Let's setup a "kde:" prefix for git commands. Add the following text to your ~/.gitconfig:
To build Qt5 and Kf5 follow the instructions in [https://community.kde.org/Frameworks/Building Frameworks/Building] on Techbase. I assume that you are building in $HOME/kf5. The result will be completely independent from your kde4 build of Krita. The frameworks instructions have the deps you need for Qt5 and kf5, but you also need Krita's own deps, of course.
<syntaxhighlight lang="ini">
[url "git://anongit.kde.org/"]
  insteadOf = kde:
[url "ssh://git@git.kde.org/"]
  pushInsteadOf = kde:
</syntaxhighlight>


==Create directories for build and installation==
you can build just the frameworks with:
<syntaxhighlight lang="bash">
sudo mkdir -p ~/kf5/{sources,build,install,logs}
sudo chown -R $USER:$GROUP ~/kf5
mkdir -p ~/.kde5/{local,config,cache}    # Optional, only if you want separate directory for config files in your home
</syntaxhighlight>


== Clone kdesrc-build ==
First you need kdesrc-build:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
cd ~/kf5/sources
./kdesrc-build frameworks
git clone kde:kdesrc-build
cd kdesrc-build
</syntaxhighlight>
</syntaxhighlight>
The rest of the commands will be run from inside this directory.


== kdesrc-build configuration==
{{Note|To get all the right things build you need Solid build, and solid depends on udev. On Ubuntu 14.04 this is package libudev-dev}}
Save the following as <code>~/.kdesrc-buildrc</code>.
<pre>
global


    #qtdir /path/to/custom/qt          # Uncomment if you have your own qt build
Here's my kdesrcbuildrc, adjust to your home directory:
    source-dir  ~/kf5/sources
    build-dir  ~/kf5/build
    kdedir  ~/kf5/install
    log-dir  ~/kf5/logs


    git-repository-base    kde-projects kde:
<syntaxhighlight lang="bash">
    branch-group            kf5-qt5
# Adjust all these settings at will


    cmake-options -DCMAKE_BUILD_TYPE:STRING=debug
global


    cxxflags -pipe -DQT_STRICT_ITERATORS -DQURL_NO_CAST_FROM_STRING -DQT_NO_HTTP -DQT_NO_FTP -Wformat -Werror=format-security -Werror=return-type -Wno-variadic-macros -Wlogical-op -Wmissing-include-dirs
  qtdir /home/boud/kf5/qt5/qtbase
  source-dir /home/boud/kf5/src
  build-dir /home/boud/kf5/build
  kdedir /home/boud/kf5/inst


    # If you want to use ninja instead of make (it's faster!), add -GNinja to cmake-options above
  git-repository-base kde-projects kde:
    # and uncomment the next line
    #custom-build-command ninja


    # Adjust to the number of  CPU cores
  cmake-options -DCMAKE_BUILD_TYPE:STRING=relwithdebinfo -DBUILD_TESTING=false
    #make-options -j2


    ignore-kde-structure    true        # Downloads all modules directly into the source folder instead of subdirectories
  # If you want to use ninja instead of make (it's faster!), uncomment the next line
    stop-on-failure        true        # Stop kdesrc-build when a build fails.
  #custom-build-command ninja


end global
  make-options -j8


include ~/kf5/sources/kdesrc-build/kf5-frameworks-build-include
  cxxflags -pipe -DQT_STRICT_ITERATORS -DQURL_NO_CAST_FROM_STRING -DQT_NO_HTTP -DQT_NO_FTP -Wformat -Werror=format-security -Werror=return-type -Wno-variadic-macros -Wlogical-op -Wmissing-include-dirs  -std=c++11
include ~/kf5/sources/kdesrc-build/kf5-workspace-build-include


#Uncomment the next two lines to build application and PIM modules
  #install-session-driver true
#include ~/kf5/sources/kdesrc-build/kf5-applications-build-include
#include ~/kf5/sources/kdesrc-build/kf5-kdepim-build-include
</pre>


* Adjust the paths to wherever you want to build and install Krita 3
  branch-group kf5-qt5
* Adjust the value of  'make-options -j4'.  It is usually recommended to set to the number of CPU cores.
* Uncomment the last two lines if you also want to build the Applications and PIM suite.


Explore other available options in the [https://kdesrc-build.kde.org/documentation/conf-options-table.html official documentation]
end global
 
=Building=
==Dependencies==
Krita 3 will need various dependencies to be installed. You can find a list of dependencies for atleast the frameworks [https://community.kde.org/Frameworks/Building#Dependencies here]. Any other dependencies can be figured out and installed as you continue building the modules one by one.
 
At the very minimum, <code>qt5</code>, <code>cmake</code>, <code>g++</code>, <code>git</code>, <code>bzr</code>, <code>libwww-perl</code>, <code>libjson-perl</code> and <code>libxml-parser-perl</code>  needs to be installed to get started.
 
===Kubuntu===
 
{{warning| Building Krita using these instructions does not work on Kubuntu due to the way they have incorrectly set up Qt.
Please use any non Debian based distro}}
 
For Kubuntu 15.04, here's a list of packages that should satisfy all the dependencies of the default kdesrc-build projects, including Frameworks, Applications and Krita Workspace but excluding kdegames. Just copy-paste this to your terminal: <pre  style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: normal;">sudo apt-get install libxslt1-dev libpolkit-agent-1-dev libpolkit-gobject-1-dev libpolkit-backend-1-dev debhelper dh-apparmor icu-devtools libboost1.55-dev libcln-dev libglib2.0-dev libgmp-dev libgmpxx4ldbl libgps-dev libicu-dev libqalculate-dev libqimageblitz-dev libqt5sensors5 libqt5sensors5-dev libqt5webkit5-dev libqt5x11extras5-dev libraw1394-dev libudev-dev libusb-dev libxapian-dev libxcb-composite0-dev libxcb-cursor-dev libxcb-cursor0 libxcb-damage0-dev libxcb-dpms0 libxcb-dpms0-dev libxcb-ewmh-dev libxcb-ewmh2 libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-record0-dev libxcb-render-util0-dev libxcb-res0 libxcb-res0-dev libxcb-screensaver0 libxcb-screensaver0-dev libxcb-shm0-dev libxcb-util0-dev libxcb-xevie0 libxcb-xevie0-dev libxcb-xf86dri0 libxcb-xf86dri0-dev libxcb-xinerama0 libxcb-xinerama0-dev libxcb-xkb-dev libxcb-xprint0 libxcb-xprint0-dev libxcb-xtest0-dev libxcb-xv0 libxcb-xv0-dev libxcb-xvmc0 libxcb-xvmc0-dev libxml2-dev pkg-kde-tools po-debconf qttools5-dev xcb-proto xvfb qtscript5-dev qtdeclarative5-dev qtbase5-dev qtbase5-dev-tools qt5-qmake doxygen bzr libjson-perl perl-modules cmake cmake-data libapr1 libaprutil1 libserf-1-1 libsvn1 libxml-parser-perl subversion git build-essential libqt5svg5-dev libgpgme11-dev libgcrypt20-dev libepoxy-dev  libssl-dev libjpeg-dev libjpeg-turbo8-dev libjpeg8-dev libgif-dev qtbase5-private-dev qtxmlpatterns5-dev-tools libqt5xmlpatterns5-dev libqt5xmlpatterns5-private-dev libvlc-dev libvlccore-dev gir1.2-gst-plugins-base-1.0 gir1.2-gstreamer-1.0 libasound2-dev libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev libnm-util-dev libnm-glib-dev libattr1-dev qtquick1-5-dev libgrantlee5-dev liblcms2-dev libexiv2-dev libarchive-dev libcups2-dev libfakekey-dev libpam-dev libxrender-dev libpng-dev libxcursor-dev liblmdb-dev libsm-dev</pre>
 
===Arch===
For Arch, here's a list of packages that should satisfy all the dependencies of the default kdesrc-build projects, including Frameworks, Applications and Krita Workspace but excluding kdegames. Just copy-paste this to your terminal: <pre  style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: normal;">
sudo pacman -S base-devel bzr cmake perl-libwww perl-xml-parser perl-json git qt5-tools docbook-xml docbook-xsl python2 boost modemmanager networkmanager vlc xapian-core xorg-server-devel
</pre>


==kdesrc-build commands==
include extragear/utils/kdesrc-build/data/build-include/kf5-qt5.ksb
Run kdesrc-build as:
<syntaxhighlight lang="bash">
./kdesrc-build --debug
</syntaxhighlight>
</syntaxhighlight>
By default, kdesrc-build sends all output to log files. --debug will print build and install progress in the terminal too.


Sometimes a build will fail, and if <code>stop-on-failure true</code> is present in the options (as above), kdesrc-build will stop here. After the reason for the build failure has been analysed and fixed, you can resume building from that module by:
The following script will setup all the paths. You should save the script as, say, ~/kf5/kf5.sh and source it when you want to do a spot of Krita3 building.
<syntaxhighlight lang="bash">
./kdesrc-build --debug --resume-from=<name>
</syntaxhighlight>


If that application build cannot be fixed at present, you can skip building it by:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
./kdesrc-build --debug --resume-after=<name>
export KF5=$HOME/kf5/inst
</syntaxhighlight>


A single module can be build using:
export QTDIR=$HOME/kf5/qt5/qtbase
<syntaxhighlight lang="bash">
export CMAKE_PREFIX_PATH=$KF5:$QTDIR:$CMAKE_PREFIX_PATH
./kdesrc-build --debug <name>
</syntaxhighlight>


Explore other options in the [https://kdesrc-build.kde.org/documentation/supported-cmdline-params.html official documentation]
export XDG_DATA_DIRS=$KF5/share:$XDG_DATA_DIRS:/usr/share
 
export XDG_CONFIG_DIRS=$KF5/etc/xdg:$XDG_CONFIG_DIRS:/etc/xdg
=Running plasma=
export XDG_DATA_HOME=$KF5/../local5/share
Save the following script as ~/kf5/runKrita5.sh
export XDG_CONFIG_HOME=$KF5/../config5
<syntaxhighlight lang="bash">
export XDG_CACHE_HOME=$KF5/../cache5
#!/bin/bash
if [ -d /etc/X11/xinit/xinitrc.d ]; then
  for f in /etc/X11/xinit/xinitrc.d/*; do
    [ -x "$f" ] && . "$f"
  done
  unset f
fi


DISTRO=`source /etc/os-release 2>/dev/null; echo $ID_LIKE`
export KF5=~/kf5/install
export QTDIR=/opt/qt5      # Change if you have your own qt build
export PATH=$KF5/bin:$QTDIR/bin:$PATH
export PATH=$KF5/bin:$QTDIR/bin:$PATH
export QT_PLUGIN_PATH=$KF5/lib/plugins:$KF5/lib64/plugins:$QTDIR/plugins:$QT_PLUGIN_PATH
#On some distros, this is $KF5/lib64/qml:$QTDIR/qml or something similar. After the installation, choose the directory/directories which contains the "qt/qml" folder.
export QML2_IMPORT_PATH=$KF5/lib/qml:$QTDIR/qml


#Fixes for Debian's "look at me, I'm so important" setups
export QT_PLUGIN_PATH=$KF5/lib/plugins:$KF5/lib64/plugins:$KF5/lib/x86_64-linux-gnu/plugins:$QTDIR/plugins:$QT_PLUGIN_PATH
if [ $DISTRO == "debian" ]
then
    export QT_PLUGIN_PATH=$KF5/lib/`uname -i`-linux-gnu/plugins:$QTDIR/plugins
    export QML2_IMPORT_PATH=$KF5/lib/`uname -i`-linux-gnu/qml:$QTDIR/qml
fi


export QML2_IMPORT_PATH=$KF5/lib/qml:$KF5/lib64/qml:$KF5/lib/x86_64-linux-gnu/qml:$QTDIR/qml
export QML_IMPORT_PATH=$QML2_IMPORT_PATH
export QML_IMPORT_PATH=$QML2_IMPORT_PATH
export XDG_DATA_DIRS=$KF5/share:/usr/share
export XDG_CONFIG_DIRS=$KF5/etc/xdg:/etc/xdg
 
# Uncomment to change default home paths
#export XDG_DATA_HOME=$HOME/.kde5/local
#export XDG_CONFIG_HOME=$HOME/.kde5/config
#export XDG_CACHE_HOME=$HOME/.kde5/cache
exec startkde
</syntaxhighlight>


==Configuring dbus==
export KDE_SESSION_VERSION=5
Because we installed Krita 3 to a custom path, we need to make dbus aware of these new locations.
export KDE_FULL_SESSION=true
export KDE_SRC=$HOME/kf5/src
Create a file /etc/dbus-1/session-local.conf with the following contents:
export KDE_BUILD=$HOME/kf5/build
<pre>
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<servicedir>~/kf5/install/share/dbus-1/services</servicedir>
</busconfig>
</pre>


Create another file /etc/dbus-1/system-local.conf with the following contents:
c=`echo -e "\033"`
<pre>
export QT_MESSAGE_PATTERN="%{appname}(%{pid})/(%{category}) ${c}[31m%{if-debug}${c}[34m%{endif}\
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
%{function}${c}[0m: %{message}"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
unset c
<busconfig>
</syntaxhighlight>
<servicedir>~/kf5/install/share/dbus-1/system-services</servicedir>
<includedir>~/kf5/install/etc/dbus-1/system.d</includedir>
</busconfig>
</pre>


Because dbus will load all these new paths each time you login, you should rename these files (to eg system-local.conf.bk and session-local.conf.bk) before starting your default Krita 4 or other distro sessions.
After building Qt and Kf5 as per instructions, you should end up with the following items in the top-level kf5 directory:


Finally, there are two ways of running Krita 3. Choose the one which suits you best.
<pre  style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: normal;">
 
~/kf5/build/
==Using a login manager==
~/kf5/cache/
The recommended login manager is SDDM. But this should method work with any login manager.
~/kf5/config5/
<syntaxhighlight lang="bash">
~/kf5/inst/
sudo cp ~/kf5/runKrita5.sh /usr/share/xsessions
~/kf5/kdesrc-build (symlink to ~/kf5/extragear/utils/kdesrc-build/kdesrc-build)
sudo chmod +x /usr/share/xsessions/runKrita5.sh
~/kf5/kdesrcbuildrc
sudo cp ~/kf5/install/share/xsessions/plasma.desktop  /usr/share/xsessions/plasmaGit.desktop
~/kf5/kf5.sh
</syntaxhighlight>
~/kf5/local5
Edit /usr/share/xsessions/plasma.desktop and change the paths as:
~/kf5/qt5/
<pre>
~/kf5/src/
Exec=/usr/share/xsessions/runKrita5.sh
TryExec=/usr/share/xsessions/runKrita5.sh
Name=Krita Git
</pre>
</pre>
After this logout of your current session, select Krita Git in the options and login. You should now have the last Krita 3 running.
==From the command line==
Edit your xinitrc file:
<syntaxhighlight lang="bash">
mv ~/.xinitrc ~/.xinitrc.bk                # Backup any existing xinitrc file
ln -s ~/kf5/runKrita5.sh ~/.xinitrc
</syntaxhighlight>
Log out of your current session, login to a tty (eg tty2 by pressing <code>Ctrl+Alt+F2</code>) and run <code>startx</code>. This should read your ~/.xinitrc and log you into a Krita 3 desktop.
=Updating=
Run kdesrc-build each time you want the latest updates.
<syntaxhighlight lang="bash">
cd ~/kf5/sources/kdesrc-build
git pull                # First update kdesrc-build
./kdesrc-build --debug
</syntaxhighlight>
=Troubleshooting=
You may not be able to successfully build or run Krita 3 at first go.
* You may not have all dependencies installed. Read the output to see what missing dependency it is complaining about, search for the corresponding package for your disto, and install it.
* If you get a build failure, simple fix might be to delete the build folder for that module and try building it again.
* Because we are compiling from the source code, some latest changes might be the cause of build failures. You may try going back to a previous code version (git skills required), wait sometime for the developers to fix the code, or even better, try to fix the build yourself and [https://techbase.kde.org/Development/Review_Board submit a patch] :)


For any help, [https://community.kde.org/Getinvolved/development#Communicating_with_the_team communicate with the KDE team].
If everything has been built, you can checkout the krita src in ~/kf5/src,  build it in ~/kf5/build and install to ~/kf5/inst. There are no weird cmake incantations needed.

Latest revision as of 17:43, 10 December 2023

This section provides information about 'building Qt5, Kf5 and Krita3.

If you want to figure out bugs in Qt5 and Kf5, you need to build those, too, and need this guide. If you just want to build krita from git master, you should be able to install the kf5 and qt5 devel packages through your package manager and build krita in the usual way.

To build Qt5 and Kf5 follow the instructions in Frameworks/Building on Techbase. I assume that you are building in $HOME/kf5. The result will be completely independent from your kde4 build of Krita. The frameworks instructions have the deps you need for Qt5 and kf5, but you also need Krita's own deps, of course.

you can build just the frameworks with:

./kdesrc-build frameworks

Note

To get all the right things build you need Solid build, and solid depends on udev. On Ubuntu 14.04 this is package libudev-dev


Here's my kdesrcbuildrc, adjust to your home directory:

# Adjust all these settings at will

global

  qtdir /home/boud/kf5/qt5/qtbase
  source-dir /home/boud/kf5/src
  build-dir /home/boud/kf5/build
  kdedir /home/boud/kf5/inst

  git-repository-base kde-projects kde:

  cmake-options -DCMAKE_BUILD_TYPE:STRING=relwithdebinfo -DBUILD_TESTING=false

  # If you want to use ninja instead of make (it's faster!), uncomment the next line
  #custom-build-command ninja

  make-options -j8

  cxxflags -pipe -DQT_STRICT_ITERATORS -DQURL_NO_CAST_FROM_STRING -DQT_NO_HTTP -DQT_NO_FTP -Wformat -Werror=format-security -Werror=return-type -Wno-variadic-macros -Wlogical-op -Wmissing-include-dirs  -std=c++11

  #install-session-driver true

  branch-group kf5-qt5

end global

include extragear/utils/kdesrc-build/data/build-include/kf5-qt5.ksb

The following script will setup all the paths. You should save the script as, say, ~/kf5/kf5.sh and source it when you want to do a spot of Krita3 building.

export KF5=$HOME/kf5/inst

export QTDIR=$HOME/kf5/qt5/qtbase
export CMAKE_PREFIX_PATH=$KF5:$QTDIR:$CMAKE_PREFIX_PATH

export XDG_DATA_DIRS=$KF5/share:$XDG_DATA_DIRS:/usr/share
export XDG_CONFIG_DIRS=$KF5/etc/xdg:$XDG_CONFIG_DIRS:/etc/xdg
export XDG_DATA_HOME=$KF5/../local5/share
export XDG_CONFIG_HOME=$KF5/../config5
export XDG_CACHE_HOME=$KF5/../cache5

export PATH=$KF5/bin:$QTDIR/bin:$PATH

export QT_PLUGIN_PATH=$KF5/lib/plugins:$KF5/lib64/plugins:$KF5/lib/x86_64-linux-gnu/plugins:$QTDIR/plugins:$QT_PLUGIN_PATH

export QML2_IMPORT_PATH=$KF5/lib/qml:$KF5/lib64/qml:$KF5/lib/x86_64-linux-gnu/qml:$QTDIR/qml
export QML_IMPORT_PATH=$QML2_IMPORT_PATH

export KDE_SESSION_VERSION=5
export KDE_FULL_SESSION=true
export KDE_SRC=$HOME/kf5/src
export KDE_BUILD=$HOME/kf5/build

c=`echo -e "\033"`
export QT_MESSAGE_PATTERN="%{appname}(%{pid})/(%{category}) ${c}[31m%{if-debug}${c}[34m%{endif}\
%{function}${c}[0m: %{message}"
unset c

After building Qt and Kf5 as per instructions, you should end up with the following items in the top-level kf5 directory:

~/kf5/build/
~/kf5/cache/
~/kf5/config5/
~/kf5/inst/
~/kf5/kdesrc-build (symlink to ~/kf5/extragear/utils/kdesrc-build/kdesrc-build)
~/kf5/kdesrcbuildrc
~/kf5/kf5.sh
~/kf5/local5
~/kf5/qt5/
~/kf5/src/

If everything has been built, you can checkout the krita src in ~/kf5/src, build it in ~/kf5/build and install to ~/kf5/inst. There are no weird cmake incantations needed.