### Build, review, and commit changes
Source: https://docs.krita.org/en/contributors_manual/krita_manual_readme.html
Install python3-sphinx (example for Ubuntu), build the manual to check for errors, review changes with git status and git diff, stage all files, commit, and push to your fork.
```bash
# install the python3-sphinx package for your system. For example for Ubuntu:
sudo apt install python3-sphinx
# build the manual (reports potential errors, allows to inspect changes in the browser)
make html
# make sure everything is correct
git status
git diff
# add all of the files
git add .
# commit your changes
git commit
# submit your changes to your fork
git push
```
--------------------------------
### Build and install Krita
Source: https://docs.krita.org/en/untranslatable_pages/building_krita.html
Activates the build environment, configures with CMake, and builds with Ninja. The resulting app is installed to $BUILDROOT/krita/_install/bin/krita.app.
```bash
# go to the Krita source directory
cd $BUILDROOT/krita
# activate the build environment (you don't need to activate
# any previous environments, like Python's venv environment;
# everything is included in this ``env`` file)
source $BUILDROOT/krita/env
source $BUILDROOT/_krita-tools/activate # if you used CI build tools
mkdir -p _build
cd _build
# configure Krita as usual
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DHIDE_SAFE_ASSERTS=OFF \
-DBUILD_TESTING=ON \
-DCMAKE_INSTALL_PREFIX=$BUILDROOT/krita/_install \
-DCMAKE_TOOLCHAIN_FILE=$BUILDROOT/krita/krita-deps-management/tools/macos-toolchain-krita.cmake \
$BUILDROOT/krita
# build and install
ninja -j8 install
```
--------------------------------
### Install build tools (CMake, Ninja, CCache)
Source: https://docs.krita.org/en/untranslatable_pages/building_krita.html
Downloads and activates the CI build tools. Skip if you already have these tools installed separately.
```bash
cd $BUILDROOT
python3 $BUILDROOT/krita/krita-deps-management/tools/download-macos-tools.py
source $BUILDROOT/_krita-tools/activate
```
--------------------------------
### Install Krita snap with snap
Source: https://docs.krita.org/en/user_manual/getting_started/installation.html
Install Krita as a snap package. Requires snapd to be installed first; snapd is installed by default on Ubuntu distributions. The snap packages are not provided or built by the Krita developers.
```bash
sudo snap install krita
```
--------------------------------
### Install Android SDK and build tools
Source: https://docs.krita.org/en/untranslatable_pages/building/build_krita_for_android.html
Install SDK licenses, platform tools, platforms, build tools, emulator, and tools using sdkmanager.
```bash
yes | sdkmanager --sdk_root=$KDECI_ANDROID_SDK_ROOT --licenses
sdkmanager --sdk_root=$KDECI_ANDROID_SDK_ROOT platform-tools
sdkmanager --sdk_root=$KDECI_ANDROID_SDK_ROOT "platforms;android-33"
sdkmanager --sdk_root=$KDECI_ANDROID_SDK_ROOT "build-tools;30.0.3"
sdkmanager --sdk_root=$KDECI_ANDROID_SDK_ROOT "build-tools;34.0.0"
sdkmanager --sdk_root=$KDECI_ANDROID_SDK_ROOT emulator
sdkmanager --sdk_root=$KDECI_ANDROID_SDK_ROOT tools
```
--------------------------------
### Install Krita build with make install
Source: https://docs.krita.org/en/untranslatable_pages/building/building_krita_on_host_linux_system.html
Run after a successful build to install Krita. The command is executed from the build directory.
```bash
you@yourcomputer:~/kritadev/build> make install
```
--------------------------------
### Install Docker
Source: https://docs.krita.org/en/untranslatable_pages/building/build_krita_with_docker_on_linux.html
Install Docker on Ubuntu or Ubuntu-based distributions using apt.
```bash
sudo apt install docker.io
```
--------------------------------
### Install ExifTool on Debian/Ubuntu
Source: https://docs.krita.org/en/contributors_manual/optimising_images.html
Install the ExifTool Perl package on Debian/Ubuntu systems using apt-get.
```bash
sudo apt-get install libimage-exiftool-perl
```
--------------------------------
### Install Krita on Arch with pacman
Source: https://docs.krita.org/en/user_manual/getting_started/installation.html
Install Krita from the Arch Linux Extra repository using the pacman package manager.
```bash
pacman -S krita
```
--------------------------------
### Start with workspace: krita --workspace Animation
Source: https://docs.krita.org/en/reference_manual/linux_command_line.html
Starts Krita with the given workspace. The example starts in the Animation workspace.
```bash
krita --workspace Animation
```
--------------------------------
### Enter the container
Source: https://docs.krita.org/en/untranslatable_pages/building/build_krita_for_android.html
Enters the running Docker container to start the build process.
```bash
# enter the container
./bin/enter
```
--------------------------------
### Run Krita
Source: https://docs.krita.org/en/untranslatable_pages/building_krita.html
Starts Krita from the command prompt after running env.bat. Both _install\bin\krita and _install\bin\krita.exe are shown as alternatives.
```batch
cd /d C:\krita-dev
env.bat
_install\bin\krita
:: or
_install\bin\krita.exe
```
--------------------------------
### Install Krita Flatpak from Flathub
Source: https://docs.krita.org/en/user_manual/getting_started/installation.html
Install the Krita Flatpak build from Flathub. This command should be run after adding the Flathub remote. The Flatpak builds are not maintained by the core developers.
```bash
flatpak --user install flathub org.kde.krita
```
--------------------------------
### Install Android system image with sdkmanager
Source: https://docs.krita.org/en/untranslatable_pages/building/build_krita_for_android.html
Install the system image for the target system. Change `x86_64` to the target architecture you would like to test.
```bash
sdkmanager --sdk_root=$KDECI_ANDROID_SDK_ROOT "system-images;android-23;google_apis;x86_64"
```
--------------------------------
### Set up Python environment
Source: https://docs.krita.org/en/untranslatable_pages/building_krita.html
Clones the Krita dependency management and CI utilities repositories, creates a Python virtual environment, and installs required Python packages. Run after creating the working directory.
```batch
git clone https://invent.kde.org/packaging/krita-deps-management.git
git clone https://invent.kde.org/packaging/krita-ci-utilities.git krita-deps-management/ci-utilities
C:\tools\Python-3.13\python.exe -m venv PythonEnv --upgrade-deps
PythonEnv\Scripts\activate.bat
python -m pip install -r krita-deps-management\requirements.txt
python -m pip install -r krita-deps-management\ci-utilities\requirements-windows.txt
```
--------------------------------
### Install Krita APK on device
Source: https://docs.krita.org/en/untranslatable_pages/building/build_krita_for_android.html
Install the Krita APK on the currently connected device or emulator using adb.
```bash
adb install ./krita-x86_64-5.2.0-prealpha-debug.apk
```
--------------------------------
### Open Krita in gdb (Linux)
Source: https://docs.krita.org/en/reference_manual/sharing_krita_logs.html
Start Krita under the gdb debugger on Linux. The command may be 'gdb krita' if installed from repositories, otherwise provide the path to the executable.
```bash
# if you have Krita installed from repositories, you may need to only write 'gdb krita'
# if not, write the path to the executable file
gdb path/to/krita
```
--------------------------------
### Install Krita on Fedora with dnf
Source: https://docs.krita.org/en/user_manual/getting_started/installation.html
Install Krita from the official Fedora repositories using the dnf package manager. Run this command in the terminal.
```bash
dnf install krita
```
--------------------------------
### Run Krita from install directory
Source: https://docs.krita.org/en/untranslatable_pages/building/building_krita_on_host_linux_system.html
Launch Krita after installation. No environment variables are required.
```bash
you@yourcomputer:~/kritadev/build>../install/bin/krita
```
--------------------------------
### cmake missing recommended packages output
Source: https://docs.krita.org/en/untranslatable_pages/building/building_krita_on_host_linux_system.html
Example output when recommended packages are missing, such as GSL required by Krita's Transform tool. This is not an error; install the missing package via your distribution's package manager.
```text
-- The following RECOMMENDED packages have not been found:
* GSL,
Required by Krita's Transform tool.
```
--------------------------------
### Set up environment without shared install feature
Source: https://docs.krita.org/en/untranslatable_pages/building/working_on_krita_deps.html
Run setup-env.py without the -s option to disable the shared install feature. For Android, pass --android-abi with one of x86_64, armeabi-v7a, or arm64-v8a.
```bash
python krita-deps-management/tools/setup-env.py -r ./ -v PythonEnv/
source /home/appimage/appimage-workspace/root/base-env
```
--------------------------------
### Create development environment with setup-env.py
Source: https://docs.krita.org/en/untranslatable_pages/building/working_on_krita_deps.html
Runs the setup-env.py script to generate environment scripts and configure the shared install folder. For Android, pass --android-abi with one of x86_64, armeabi-v7a, or arm64-v8a.
```bash
python krita-deps-management/tools/setup-env.py -r ./ -v PythonEnv/ -s /home/appimage/appimage-workspace/deps/usr
```
--------------------------------
### Example output of show-updates-status.py
Source: https://docs.krita.org/en/untranslatable_pages/release_krita.html
Example output from the show-updates-status.py command. It shows the status of each channel (Stable, Beta, Plus, Next) with ZSync URL, AppImage existence, and file details. Use it to verify that no channels are marked FAILED and that the AppImage filename and URL are correct.
```text
== Channel: Stable FAILED ==
ZSync URL: https://download.kde.org/stable/krita/updates/Krita-Stable-x86_64.appimage.zsync
ZSync exists: True
AppImage exists: False
MTime: Wed, 06 Dec 2023 13:28:16 +0000
Filename: krita-5.2.2-x86_64.appimage
URL: https://binary-factory.kde.org/job/Krita_Release_Appimage_Build/124//artifact/krita-5.2.2-x86_64.appimage
SHA-1: 16a1a640084446b45ea078d8b81cffc075144a02
== Channel: Beta (unstable) FAILED ==
ZSync URL: https://download.kde.org/unstable/krita/updates/Krita-Beta-x86_64.appimage.zsync
ZSync exists: True
AppImage exists: False
MTime: Thu, 14 Sep 2023 09:26:05 +0000
Filename: krita-5.2.0-rc1-x86_64.appimage
URL: https://binary-factory.kde.org/job/Krita_Release_Appimage_Build/121//artifact/krita-5.2.0-rc1-x86_64.appimage
SHA-1: 4bd0f522c22f41e504bf1e9ced540fa11ed5ec53
== Channel: Plus FAILED ==
ZSync URL: https://cdn.kde.org/ci-builds/graphics/krita/krita/5.2/linux/Krita-Plus-x86_64.appimage.zsync
ZSync exists: False
AppImage exists: False
== Channel: Next ==
ZSync URL: https://cdn.kde.org/ci-builds/graphics/krita/master/linux/Krita-Next-x86_64.appimage.zsync
ZSync exists: True
AppImage exists: True
MTime: Tue, 02 Apr 2024 22:30:57 +0000
Filename: krita-5.3.0-prealpha-64b33ed808-x86_64.appimage
URL: https://cdn.kde.org/ci-builds/graphics/krita/master/linux/krita-5.3.0-prealpha-64b33ed808-x86_64.appimage
SHA-1: e360127c3c956499ed0266ad8eb9bcdad3789956
```
--------------------------------
### Install Python dependencies with venv
Source: https://docs.krita.org/en/untranslatable_pages/building/build_krita_for_android.html
Sets up a Python virtual environment and installs the requirements from the management repository. Optionally use venv for isolation.
```bash
# set up venv
python3 -m venv --upgrade-deps $WORKDIR/PythonEnv
source $WORKDIR/PythonEnv/bin/activate
# install requirements
python -m pip install -r $SRCDIR/krita/krita-deps-management/requirements.txt
```
--------------------------------
### Example test using QVERIFY and QCOMPARE
Source: https://docs.krita.org/en/untranslatable_pages/unit_tests_in_krita.html
Shows how to write assertions in a test method. QVERIFY checks a condition, QCOMPARE compares two values.
```cpp
void KisSomeClassTest::test()
{
QString cat("cat");
QString dog("dog");
QVERIFY(cat != dog);
QCOMPARE(cat, "cat");
}
```
--------------------------------
### Install Krita on Debian with apt
Source: https://docs.krita.org/en/user_manual/getting_started/installation.html
Install Krita from the Debian repositories using the apt package manager. The latest version available in Debian is 3.1.1.
```bash
apt install krita
```
--------------------------------
### Install Java 17 via PPA
Source: https://docs.krita.org/en/untranslatable_pages/building/build_krita_for_android.html
Install exactly version 17 of OpenJDK. Remove any other Java versions or ensure update-alternatives selects version 17 for both javac and the runtime.
```bash
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-17-jdk # exactly this version!
```
--------------------------------
### Start ssh-agent service
Source: https://docs.krita.org/en/untranslatable_pages/setting_up_ssh_agent_on_kde_neon.html
Start the ssh-agent user service.
```bash
systemctl --user start ssh-agent.service
```
--------------------------------
### Rebuild and install after update
Source: https://docs.krita.org/en/untranslatable_pages/building/building_krita_on_host_linux_system.html
Rebuild the project and install after pulling new source. Run from the build directory.
```bash
you@yourcomputer:~/kritadev/krita> cd ~/kritadev/build/
you@yourcomputer:~/kritadev/build> make install
```
--------------------------------
### Build Krita
Source: https://docs.krita.org/en/untranslatable_pages/building/build_krita_for_android.html
Builds and installs Krita using make with 8 parallel jobs.
```bash
make -j8 install
```
--------------------------------
### Console output of printf example
Source: https://docs.krita.org/en/reference_manual/seexpr.html
The expected console output produced by the printf example above.
```text
test 1 [4,5,6]
```
--------------------------------
### Install Rust and rcodesign in Docker container
Source: https://docs.krita.org/en/untranslatable_pages/building_krita.html
Commands to install Rust and rcodesign inside the KDE signing docker container. Run the first two lines as superuser via ./bin/sudoenter, then the rest as the non-privileged 'appimage' user via ./bin/enter. cargo-1.80 install apple-codesign installs rcodesign, and prepend PATH adds its binary to the PATH.
```bash
# install Rust as a superuser
./bin/sudoenter
apt install rust-1.80-all
# install rcodesign as non-privileged `appimage` user
./bin/enter
cargo-1.80 install apple-codesign
prepend PATH /home/appimage/.cargo/bin
```
--------------------------------
### Build Krita inside the container
Source: https://docs.krita.org/en/untranslatable_pages/building/build_krita_with_docker_on_linux.html
Run these commands inside the container to build and install Krita. You should be in the '~/appimage-workspace/krita-build/' directory. The commands configure with CMake, build with make, and start Krita.
```bash
# build Krita as usual
# you should be in ~/appimage-workspace/krita-build/
~/bin/run_cmake.sh ~/persistent/krita
make -j8 install
# start Krita
../krita.appdir/usr/bin/krita
```
--------------------------------
### Fetch Krita sources and set up Python virtual environment
Source: https://docs.krita.org/en/untranslatable_pages/building_krita.html
Clones the Krita source repository and the build scripts, then creates a Python virtual environment and installs required packages.
```bash
cd $BUILDROOT
git clone https://invent.kde.org/graphics/krita.git
# fetch environment scripts under Krita's source directory
cd krita
git clone https://invent.kde.org/packaging/krita-deps-management.git krita-deps-management --depth=1
git clone https://invent.kde.org/packaging/krita-ci-utilities.git krita-deps-management/ci-utilities --depth=1
# create venv environment for running build scripts
python3 -m venv $BUILDROOT/venv --upgrade-deps
source $BUILDROOT/venv/bin/activate
pip install -r krita-deps-management/requirements.txt
```
--------------------------------
### Install clang-tidy 11 on Ubuntu
Source: https://docs.krita.org/en/untranslatable_pages/enable_static_analyzer.html
Installs clang-11, clang-format-11, clang-tidy-11, and clang-tools-11. Requires the backports repository for older Ubuntu versions.
```bash
sudo apt install clang-11 clang-format-11 clang-tidy-11 clang-tools-11
```
--------------------------------
### Rebuild and deploy Krita package
Source: https://docs.krita.org/en/untranslatable_pages/building/build_krita_for_android.html
Run the build and deploy steps in one line. This rebuilds Krita, builds a debug package, installs it on the connected device, and launches Krita.
```bash
cd cd $SRCDIR/krita/_build/krita_build_apk
make -j8 install -C .. && ./gradlew installDebug && adb shell am start -n "org.krita.debug/org.krita.android.MainActivity"
```
--------------------------------
### Create Krita build directory structure
Source: https://docs.krita.org/en/untranslatable_pages/building/building_krita_on_host_linux_system.html
Sets up the recommended layout with source, build, and install directories under a build root. Commands are shown after the '>' prompt.
```bash
you@yourcomputer:~>cd
you@yourcomputer:~>mkdir kritadev
you@yourcomputer:~/>cd kritadev
you@yourcomputer:~/kritadev> mkdir build
you@yourcomputer:~/kritadev> mkdir install
```
--------------------------------
### Install cpu-checker and check KVM support
Source: https://docs.krita.org/en/untranslatable_pages/building/build_krita_for_android.html
Install cpu-checker and verify KVM virtualization support on the host or in the docker container. KVM is required for x86_64 builds but not for ARM targets.
```bash
sudo apt-get install cpu-checker
# Check if kvm is available
kvm-ok
```
--------------------------------
### Example ssh-agent service file
Source: https://docs.krita.org/en/untranslatable_pages/setting_up_ssh_agent_on_kde_neon.html
Example systemd service file for ssh-agent. Modify the timeout with the -t flag if needed.
```ini
[Unit]
Description=OpenSSH Agent
Documentation=man:ssh-agent(1)
Before=graphical-session-pre.target
Wants=dbus.socket
After=dbus.socket
[Service]
ExecStart=/usr/lib/openssh/agent-launch start -- -t 60m
ExecStopPost=/usr/lib/openssh/agent-launch stop
```
--------------------------------
### Install Python 3.10 and 3.13 with choco for Krita branches
Source: https://docs.krita.org/en/untranslatable_pages/building_krita.html
Use this choco script to install two Python versions without adding them to %PATH%: Python 3.10 for the legacy stable branch (krita/5.2) and Python 3.13 for master. The /InstallDir parameter sets the installation folder, and the install-arguments disable PATH prepending/appending and optional components.
```powershell
choco install -y python310 --params "/InstallDir:C:\tools\Python-3.10" --install-arguments="PrependPath=0 AppendPath=0 Include_doc=0 Include_test=0 Include_launcher=0"
choco install -y python313 --params "/InstallDir:C:\tools\Python-3.13" --install-arguments="PrependPath=0 AppendPath=0 Include_doc=0 Include_test=0 Include_launcher=0"
```
--------------------------------
### Install utility packages
Source: https://docs.krita.org/en/untranslatable_pages/building/build_krita_with_docker_on_linux.html
Install python3, python3-venv, python3-pip, and wget. The python3-venv package is required for bootstrapping dependencies on the host system before building the Docker image.
```bash
sudo apt install python3 python3-venv python3-pip wget
```
--------------------------------
### Run QtCreator from host system
Source: https://docs.krita.org/en/untranslatable_pages/building/build_krita_with_docker_on_linux.html
Use this script from the host system to run QtCreator installed in the docker container at ~/qtcreator. Requires QtCreator to be installed in the container without version suffixes.
```bash
# from the host
./bin/qtcreator
```
--------------------------------
### Debug Krita with lldb
Source: https://docs.krita.org/en/untranslatable_pages/building_krita.html
Starts lldb on the Krita executable and runs it. The output shows the target being created and the run command.
```bash
cd $BUILDROOT/krita
lldb ./_install/bin/krita.app/Contents/MacOS/krita
(lldb) target create "./_install/bin/krita.app/Contents/MacOS/krita"
Current executable set to './_install/bin/krita.app/Contents/MacOS/krita' (x86_64).
(lldb) r
```
--------------------------------
### Build Krita with unit tests enabled using cmake
Source: https://docs.krita.org/en/untranslatable_pages/unit_tests_in_krita.html
Use this command to configure a Krita build with unit tests enabled. Requires the -DBUILD_TESTING=ON flag. The example sets CMAKE_INSTALL_PREFIX, CMAKE_BUILD_TYPE, and KRITA_DEVS options.
```bash
# example build command
you@yourcomputer:~/kritadev/build>cmake ../krita \
-DCMAKE_INSTALL_PREFIX=$HOME/kritadev/install \
-DCMAKE_BUILD_TYPE=Debug \
-DKRITA_DEVS=ON \
-DBUILD_TESTING=ON
```
--------------------------------
### Open template example: krita --template /home/username/sketchbook/sketch-template-page.kra
Source: https://docs.krita.org/en/reference_manual/linux_command_line.html
Opens the file sketch-template-page.kra as a template.
```bash
krita --template /home/username/sketchbook/sketch-template-page.kra
```
--------------------------------
### Set up environment and fetch prebuilt dependencies
Source: https://docs.krita.org/en/untranslatable_pages/building_krita.html
Activates the Python virtual environment and CI tools, then runs setup-env.py to download prebuilt dependencies and generate the build environment. This step is only needed once.
```bash
cd $BUILDROOT/krita
source $BUILDROOT/venv/bin/activate
source $BUILDROOT/_krita-tools/activate # if you used CI build tools
python krita-deps-management/tools/setup-env.py --full-krita-env -v $BUILDROOT/venv -p $BUILDROOT/$KDECI_CRAFT_PLATFORM/dev-utils/bin/
```
--------------------------------
### Profile guided optimization with g++
Source: https://docs.krita.org/en/untranslatable_pages/optimizing_tips_for_krita.html
Compile with profile generation, run the benchmark, then recompile with profile use to optimize based on actual usage.
```cpp
g++ -O3 -march=native -pg -fprofile-generate ...
// run my program's benchmark
g++ -O3 -march=native -fprofile-use ...
```
--------------------------------
### Install development dependencies from dev-requirements.txt
Source: https://docs.krita.org/en/untranslatable_pages/python_coding.html
Installs or updates the Python packages required for code checks and unit tests from the Krita repository's dev-requirements.txt file. Rerun to update packages when version numbers change.
```bash
pip install --upgrade -r dev-tools/python/dev-requirements.txt
```
--------------------------------
### Set up working directory and environment
Source: https://docs.krita.org/en/untranslatable_pages/building/build_krita_for_android.html
Configures the build environment: runs setup-env.py with the venv path, ABI, and workdir root, then activates the generated environment and fetches dependencies. The generated environment file is activated with 'source ./env'.
```bash
cd $SRCDIR/krita
python krita-deps-management/tools/setup-env.py \
# Path to our venv to make sure it is automatically activated in this environment
-v $WORKDIR/PythonEnv \
# select target ABI
--android-abi $KDECI_ANDROID_ABI \
# select workdir root (where the caches and downloads will go)
--root $WORKDIR
# activate the generated environment
source $WORKDIR/base-env
# generate deps file
python krita-deps-management/tools/generate-deps-file.py \
-s krita-deps-management/latest/krita-deps.yml \
-o .kde-ci.yml
# fetch the dependencies
python krita-deps-management/ci-utilities/run-ci-build.py \
# requitred fields for the script
--project krita --branch master \
# platform for which to fetch dependencies
--platform Android/$KDECI_ANDROID_ABI \
# only generate environment file in `./env`
--only-env
# activate generated environment
source ./env
```
--------------------------------
### Set up folders and Python environment
Source: https://docs.krita.org/en/untranslatable_pages/building/working_on_krita_deps.html
Creates the workspace root, clones the dependency management and CI utilities repositories, and initializes a Python virtual environment with required modules.
```bash
mkdir /home/appimage/appimage-workspace/root
cd /home/appimage/appimage-workspace/root
git clone https://invent.kde.org/packaging/krita-deps-management.git
git clone https://invent.kde.org/packaging/krita-ci-utilities.git krita-deps-management/ci-utilities
python3 -m venv PythonEnv
source ./PythonEnv/bin/activate
pip install -r krita-deps-management/requirements.txt
```
--------------------------------
### Install Krita build dependencies on Ubuntu
Source: https://docs.krita.org/en/untranslatable_pages/building/building_krita_on_host_linux_system.html
Installs all dependencies of the Krita version in the repositories. May require enabling deb-src repositories.
```bash
you@yourcomputer:~/kritadev/build>apt-get build-dep krita
```
--------------------------------
### Open Krita in lldb (macOS)
Source: https://docs.krita.org/en/reference_manual/sharing_krita_logs.html
Start Krita under the lldb debugger on macOS using the path to the Krita executable.
```bash
lldb /Applications/krita.app/Contents/MacOS/krita
```
--------------------------------
### Download dependencies and generate environment file
Source: https://docs.krita.org/en/untranslatable_pages/building_krita.html
Runs setup-env.py to download dependencies and generate the env.bat file. Replace the paths to llvm-mingw and ninja with your actual paths. If you hand-craft the PATH variable, ensure it does not contain double backslashes (\\), as ASAN symbolizer will crash when parsing error-reports.
```batch
python krita-deps-management\tools\setup-env.py --full-krita-env -v PythonEnv -p c:\deps\llvm-mingw-20251118-ucrt-x86_64\bin\ -p c:\deps\llvm-mingw-20251118-ucrt-x86_64\x86_64-w64-mingw32\bin\ -p c:\deps\Ninja\
```
--------------------------------
### Create a Python 3 virtual environment with mkvirtualenv
Source: https://docs.krita.org/en/untranslatable_pages/python_coding.html
Creates and activates a virtual environment named 'krita' using Python 3. After running, the command line prompt starts with (krita) to indicate the active environment.
```bash
mkvirtualenv krita -p /usr/bin/python3
```
--------------------------------
### Set up source and environment directories
Source: https://docs.krita.org/en/untranslatable_pages/building/build_krita_for_android.html
Defines SRCDIR and ENVDIR for storing sources/build artifacts and packages/caches respectively, then creates them.
```bash
export SRCDIR=/home/appimage/persistent/sources
export ENVDIR=/home/appimage/persistent/envdir
mkdir -p $SRCDIR
mkdir -p $ENVDIR
```
--------------------------------
### printf example with vector formatting
Source: https://docs.krita.org/en/reference_manual/seexpr.html
Shows how to use the printf function to format a float and a vector. The output is printed to stdout as 'test 1 [4,5,6]'.
```seexpr
$u = printf("test %f %v",[1,2,3],[4,5,6]);
```
--------------------------------
### Ternary if operator example
Source: https://docs.krita.org/en/reference_manual/seexpr.html
Example of the ternary if operator ?:.
```seexpr
$u < .5 ? 0 : 1
```
--------------------------------
### Run Krita AppImage
Source: https://docs.krita.org/en/user_manual/getting_started/installation.html
Run the Krita AppImage from the terminal after making it executable. The example uses the filename krita-3.0-x86_64.appimage; replace it with your actual AppImage filename.
```bash
./krita-3.0-x86_64.appimage
```
--------------------------------
### Set ANDROID_ROOT prefix variable
Source: https://docs.krita.org/en/untranslatable_pages/building/build_krita_for_android.html
Configure the prefix variable where SDKs and NDK will be installed. Adjust the path to your workspace.
```bash
export ANDROID_ROOT=/home/appimage/appimage-workspace/android/
```
--------------------------------
### Verbose build commands for GNU Make and Ninja
Source: https://docs.krita.org/en/untranslatable_pages/building/working_on_krita_deps.html
Pass these options to GNU Make or Ninja when starting the build manually to see exact build command lines, useful for triaging CI bugs.
```bash
# for GNU Make
make VERBOSE=1 all
# for Ninja
ninja -v
```
--------------------------------
### Build Docker image without prebuilt dependencies (-s / --skip-deps)
Source: https://docs.krita.org/en/untranslatable_pages/building/working_on_krita_deps.html
Pass the -s (or --skip-deps) option to build_image to create a container image without any prebuilt dependencies installed.
```bash
./bin/build-image -s
```
--------------------------------
### Create and enter build directory
Source: https://docs.krita.org/en/untranslatable_pages/building/build_krita_for_android.html
Creates the build directory and enters it. The location is tightly linked to $KDECI_WORKDIR_PATH in packaging scripts; do not change it. Building without KDECI_WORKDIR_PATH will cause androiddeployqt to skip QML modules.
```bash
mkdir -p /home/appimage/appimage-workspace/krita/_build
cd /home/appimage/appimage-workspace/krita/_build
```
--------------------------------
### Install NVidia GPU drivers in the docker container
Source: https://docs.krita.org/en/untranslatable_pages/building/build_krita_with_docker_on_linux.html
Run this script on the host system to install the same version of the proprietary NVidia driver as on the host. The docker run script forwards GPU devices but does not install drivers.
```bash
./bin/install_nvidia_drivers.sh
```
--------------------------------
### Create working directory
Source: https://docs.krita.org/en/untranslatable_pages/building_krita.html
Creates the working directory C:\krita-dev and changes into it. Keep the prefix path short (30 characters is fine) and avoid whitespace to prevent build errors.
```batch
mkdir C:\krita-dev
cd /d C:\krita-dev
```
--------------------------------
### Configure and build Krita
Source: https://docs.krita.org/en/untranslatable_pages/building_krita.html
Configures the build with CMake and builds with Ninja. If building with ASAN, do not use prebuilt deps; rebuild Qt with ASAN support (-DQT_ENABLE_ASAN=ON) as a workaround for a known LLVM linker issue.
```batch
cd /d C:\krita-dev
env.bat
mkdir -p C:\krita-dev\b_krita
cd b_krita
cmake C:\krita-dev\krita ^
-DCMAKE_INSTALL_PREFIX=C:/krita-dev/_install ^
-DBUILD_TESTING=ON ^
-DINSTALL_BENCHMARKS=ON ^
-DKRITA_ENABLE_PCH=OFF ^
-DHIDE_SAFE_ASSERTS=OFF ^
-G Ninja ^
-DCMAKE_BUILD_TYPE=RelWithDebInfo
ninja -j8 install
```
--------------------------------
### Clone the container
Source: https://docs.krita.org/en/untranslatable_pages/building/build_krita_with_docker_on_linux.html
Run this command on the host system to copy the container to '../krita-auto-2'. The clone includes the entire environment, sources, build directory, and QtCreator installation, so no rebuild is needed.
```bash
./bin/spawn-clone -d ../krita-auto-2
```
--------------------------------
### Set up environment variables in container
Source: https://docs.krita.org/en/untranslatable_pages/building/build_krita_for_android.html
Sets ANDROID_ROOT, KDECI_ANDROID_SDK_ROOT, KDECI_ANDROID_NDK_ROOT, ANDROID_HOME, and PATH via setup-environment.sh, then exports KDECI_ANDROID_ABI, KDECI_WORKDIR_PATH, and KDECI_SHARED_INSTALL_PATH. These variables must be set every time you enter the container.
```bash
# sets ANDROID_ROOT, KDECI_ANDROID_SDK_ROOT, KDECI_ANDROID_NDK_ROOT, ANDROID_HOME, and PATH (for tools necessary for the SDK)
source /var/lib/ci-files/setup-environment.sh
# set ABI you are building for
export KDECI_ANDROID_ABI=x86_64
# location where _build and _packaging folders will be located
# (don't change)
export KDECI_WORKDIR_PATH=/home/appimage/appimage-workspace
# location where the dependencies were unpacked (don't change)
export KDECI_SHARED_INSTALL_PATH=/home/appimage/appimage-workspace/deps/usr
```
--------------------------------
### Configure Krita build with cmake
Source: https://docs.krita.org/en/untranslatable_pages/building/building_krita_on_host_linux_system.html
Generates the build system in the build directory. Sets install prefix, Debug build type, and enables KRITA_DEVS. Missing dependencies will be reported.
```bash
you@yourcomputer:~/kritadev/build>cmake ../krita \
-DCMAKE_INSTALL_PREFIX=$HOME/kritadev/install \
-DCMAKE_BUILD_TYPE=Debug \
-DKRITA_DEVS=ON
```
--------------------------------
### Create buildroot folder
Source: https://docs.krita.org/en/untranslatable_pages/building_krita.html
Sets up the BUILDROOT environment variable and creates the directory where Krita sources and build artifacts will be stored.
```bash
export BUILDROOT=$HOME/dev
mkdir -p $BUILDROOT
cd $BUILDROOT
```
--------------------------------
### Apply operator examples
Source: https://docs.krita.org/en/reference_manual/seexpr.html
Examples of the apply operator ->, where the function on the right is applied to the expression on the left.
```seexpr
$Cs->contrast(.7) -> clamp(0.2,0.8)
```
```seexpr
$u->hsi(20,1.2,1,$Cs->gamma(1.2))
```
--------------------------------
### Reactivate the virtual environment with workon
Source: https://docs.krita.org/en/untranslatable_pages/python_coding.html
Re-enters the previously created virtual environment named 'krita'.
```bash
workon krita
```
--------------------------------
### Derive from QImageBasedTest for complex actions
Source: https://docs.krita.org/en/untranslatable_pages/unit_tests_in_krita.html
Example from KisProcessingsTest. Override QImageBasedTest and call the test method to create an image, apply a visitor, and verify results. On failure, PNG images are saved to the working directory.
```cpp
// override QImageBasedTest class
class BaseProcessingTest : public TestUtil::QImageBasedTest
{
public:
BaseProcessingTest()
: QImageBasedTest("processings")
{
}
// The method is called by test cases. If the test fails, a set of PNG images
// is saved into working directory
void test(const QString &testname, KisProcessingVisitorSP visitor) {
// create an image and regenerate its projection
KisSurrogateUndoStore *undoStore = new KisSurrogateUndoStore();
KisImageSP image = createImage(undoStore);
image->initialRefreshGraph();
// check if the image is correct before testing anything
QVERIFY(checkLayersInitial(image));
// do the action we are trying to test
KisProcessingApplicator applicator(image, image->root(),
KisProcessingApplicator::RECURSIVE);
applicator.applyVisitor(visitor);
applicator.end();
image->waitForDone();
// check the result, and dump images if something went wrong
QVERIFY(checkLayers(image, testname));
// Check if undo(!) works correctly
undoStore->undo();
image->waitForDone();
if (!checkLayersInitial(image)) {
qWarning() << "NOTE: undo is not completely identical "
<< "to the original image. Falling back to "
<<"projection comparison";
QVERIFY(checkLayersInitialRootOnly(image));
}
}
};
```
--------------------------------
### Build Krita with make
Source: https://docs.krita.org/en/untranslatable_pages/building/building_krita_on_host_linux_system.html
Builds Krita after cmake configuration succeeds. Requires the Qt5 SQLite database driver package (e.g., libqt5sql5-sqlite on Ubuntu) to start Krita later.
```bash
you@yourcomputer:~/kritadev/build> make
```
--------------------------------
### Basic Extension Class
Source: https://docs.krita.org/en/user_manual/python_scripting/krita_python_plugin_howto.html
Defines the minimal structure for a Krita extension by subclassing Extension. The setup() and createActions() methods are required but left empty. The extension is registered with Krita.instance().addExtension().
```python
from krita import *
class MyExtension(Extension):
def __init__(self, parent):
# This is initialising the parent, always important when subclassing.
super().__init__(parent)
def setup(self):
pass
def createActions(self, window):
pass
# And add the extension to Krita's list of extensions:
Krita.instance().addExtension(MyExtension(Krita.instance()))
```
--------------------------------
### RST code:: Directive with Python Example
Source: https://docs.krita.org/en/contributors_manual/krita_manual_conventions.html
Shows the '.. code::' directive with a language name for syntax highlighting, using a Python example.
```reStructuredText
.. code:: python
# Python comment
def my_function():
alist = []
alist.append(1)
string = "hello world"
```
--------------------------------
### Add backports repository for older Ubuntu
Source: https://docs.krita.org/en/untranslatable_pages/enable_static_analyzer.html
Required for older Ubuntu versions (e.g., Krita Docker build environment) to access LLVM 11 packages. Run before installing clang-tidy.
```bash
sudo add-apt-repository ppa:savoury1/llvm-defaults-11
sudo apt-get update
```
--------------------------------
### Search for quazip package with apt-cache
Source: https://docs.krita.org/en/untranslatable_pages/building/building_krita_on_host_linux_system.html
Shows available quazip packages. Select the 'dev' library for Qt5 (libquazip5-dev) because Krita uses Qt5.
```bash
you@yourcomputer:~/kritadev/build>apt-cache search quazip
libquazip-dev - C++ wrapper for ZIP/UNZIP (development files, Qt4 build)
libquazip-doc - C++ wrapper for ZIP/UNZIP (documentation)
libquazip-headers - C++ wrapper for ZIP/UNZIP (development header files)
libquazip1 - C++ wrapper for ZIP/UNZIP (Qt4 build)
libquazip5-1 - C++ wrapper for ZIP/UNZIP (Qt5 build)
libquazip5-dev - C++ wrapper for ZIP/UNZIP (development files, Qt5 build)
libquazip5-headers - C++ wrapper for ZIP/UNZIP (development header files, Qt5 build)
```
--------------------------------
### Build a single dependency with run-ci-build.py
Source: https://docs.krita.org/en/untranslatable_pages/building/working_on_krita_deps.html
Builds a dependency by running the CI build script from its subfolder. Change the --project and --platform arguments; possible platforms are Linux, Windows, MacOS, Android/x86_64, Android/armeabi-v7a, Android/arm64-v8a.
```bash
cd krita-deps-management/ext_qt/
python -u ../ci-utilities/run-ci-build.py --project ext_qt --branch master --platform Linux -e env --skip-dependencies-fetch
```
--------------------------------
### Comment out SSH_AUTH_SOCK setup in /etc/profile.d/org.kde.neon.ksshaskpass_auth_sock.sh
Source: https://docs.krita.org/en/untranslatable_pages/setting_up_ssh_agent_on_kde_neon.html
Disable the explicit SSH_AUTH_SOCK setup by commenting out the file contents, as it will be set by ssh-agent.service.
```bash
# SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
# SPDX-FileCopyrightText: 2026 Carlos De Maine
# NOTE: Disabled! Will be set by ssh-agent.service!
# in a wayland seesion the SSH_AUTH_SOCK needs to be set as below
# in a X11 session this is set automatically and thus does not need to be done here
# if [ "$XDG_SESSION_TYPE" = "wayland" ]; then
# export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"
# fi
```
--------------------------------
### Source file for test class (kis_some_class_test.cpp)
Source: https://docs.krita.org/en/untranslatable_pages/unit_tests_in_krita.html
Implements the test method and includes the QTEST_MAIN macro with GUI argument to generate the test executable.
```cpp
#include "kis_some_class_test.h"
#include
void KisSomeClassTest::test()
{
}
QTEST_MAIN(KisSomeClassTest, GUI)
```
--------------------------------
### Example .kts taskset XML file
Source: https://docs.krita.org/en/reference_manual/dockers/task_sets.html
Task sets are stored as .kts files, which are XML files. This example shows the structure with a Taskset element and action elements.
```xml
add_new_paint_layer
add_new_clone_layer
add_new_file_layer
```
--------------------------------
### Build all packages with publish-to-cache
Source: https://docs.krita.org/en/untranslatable_pages/building/working_on_krita_deps.html
Run seed-package-registry.py with --publish-to-cache and --missing-only to build all packages in isolated environments. Rerun after fixing failures; --missing-only skips successfully built subprojects.
```bash
cd krita-deps-management
python -u ../ci-utilities/seed-package-registry.py --platform Linux --seed-file latest/krita-deps.yml --publish-to-cache --missing-only
```
--------------------------------
### Stop and start the Krita docker container
Source: https://docs.krita.org/en/untranslatable_pages/building/build_krita_with_docker_on_linux.html
Stop the container to save filesystem state and kill running processes; start it again to resume. Ensure you logout from all terminals before stopping.
```bash
# stop the container
./bin/stop
# start the container
./bin/start
```
--------------------------------
### Starting a stroke with KisStrokesFacade
Source: https://docs.krita.org/en/untranslatable_pages/strokes_documentation.html
Use the KisStrokesFacade interface to start, add jobs to, and end or cancel a stroke. The stroke ID handle is used in all subsequent calls. Only one stroke executes at a time on the CPU.
```cpp
KisStrokeId strokeId = strokesFacade->startStroke(myStrategy);
```
```cpp
strokesFacade->addJob(strokeId, myData);
```
```cpp
strokesFacade->endStroke(strokeId);
```
```cpp
strokesFacade->cancelStroke(strokeId);
```
--------------------------------
### Summary: __init__.py and desktop file for myplugin
Source: https://docs.krita.org/en/user_manual/python_scripting/krita_python_plugin_howto.html
Summary of the required files for a plugin named myplugin. The __init__.py imports the main module, and the .desktop file registers the plugin. Place both in the resources/pykrita directory structure.
```python
from .myplugin import *
```
```ini
[Desktop Entry]
Type=Service
ServiceTypes=Krita/PythonPlugin
X-KDE-Library=myplugin
X-Python-2-Compatible=false
Name=My Own Plugin
Comment=Our very own plugin.
```
--------------------------------
### Run callgrind with instrumentation off at start
Source: https://docs.krita.org/en/untranslatable_pages/optimizing_tips_for_krita.html
Use this command to start Krita under callgrind without instrumentation, useful for focusing on specific parts of the code like drawing a stroke. Instrumentation can be toggled later with callgrind_control.
```bash
valgrind --tool=callgrind --instr-atstart=no krita
```
--------------------------------
### Activate environment
Source: https://docs.krita.org/en/untranslatable_pages/building_krita.html
Opens a CMD window, changes to C:\krita-dev, and runs the env.bat file generated by setup-env.py. You only need to run env.bat once per CMD window, even though most command samples below include these two lines.
```batch
cd /d C:\krita-dev
env.bat
```
--------------------------------
### Run all Krita unit tests with make test
Source: https://docs.krita.org/en/untranslatable_pages/unit_tests_in_krita.html
Run the entire test suite from the build directory. First change to the build directory, then execute 'make test'.
```bash
# change to the build directory
you@yourcomputer:~/> cd kritadev/build
# run the whole suite
you@yourcomputer:~/kritadev/build> make test
```
--------------------------------
### Enter build directory
Source: https://docs.krita.org/en/untranslatable_pages/building/building_krita_on_host_linux_system.html
Changes into the build directory before configuring the build.
```bash
you@yourcomputer:~/kritadev> cd build
```
--------------------------------
### Get backtrace in lldb
Source: https://docs.krita.org/en/reference_manual/sharing_krita_logs.html
Obtain a backtrace of all threads after Krita crashes.
```lldb
thread backtrace all
```
--------------------------------
### Download Qt6 prebuilt Krita dependencies
Source: https://docs.krita.org/en/untranslatable_pages/building/build_krita_with_docker_on_linux.html
Use this command instead of the default bootstrap when building a Qt6 version of Krita. It downloads the Qt6 dependencies archive.
```bash
# download the qt6 deps archive
./bin/bootstrap-deps.sh -b transition.now/qt6
```
--------------------------------
### HTML Code Example
Source: https://docs.krita.org/en/contributors_manual/krita_manual_conventions.html
An HTML paragraph with an inline style and an HTML comment.
```html
this is a paragraph.
```
--------------------------------
### Get long backtrace in gdb
Source: https://docs.krita.org/en/reference_manual/sharing_krita_logs.html
Obtain a long backtrace with full details for all threads.
```gdb
thread apply all bt full
```
--------------------------------
### Create a new document with createDocument
Source: https://docs.krita.org/en/user_manual/python_scripting/introduction_to_python_scripting.html
Creates a 512x512 document named 'Python test document' with RGBA, U8, and 120.0 DPI, then adds a view to the active window. Demonstrates basic Krita automation.
```python
from krita import *
d = Krita.instance().createDocument(512, 512, "Python test document", "RGBA", "U8", "", 120.0)
Krita.instance().activeWindow().addView(d)
```
--------------------------------
### Get short backtrace in gdb
Source: https://docs.krita.org/en/reference_manual/sharing_krita_logs.html
Obtain a short backtrace of all threads after Krita crashes.
```gdb
thread apply all bt
```
--------------------------------
### Source the generated environment file
Source: https://docs.krita.org/en/untranslatable_pages/building/working_on_krita_deps.html
Activates the environment for the current session. Repeat this line each time you enter the container.
```bash
source /home/appimage/appimage-workspace/root/base-env
```
--------------------------------
### Disable pagination in gdb
Source: https://docs.krita.org/en/reference_manual/sharing_krita_logs.html
Disable pagination in gdb to avoid prompts when getting backtraces.
```gdb
set pagination off
```
--------------------------------
### Create state and cursor with Lager
Source: https://docs.krita.org/en/untranslatable_pages/brush_editor_gui_with_lager.html
Shows how to create a Lager state and connect a cursor to a subvalue, then read, write, and bind it to a Qt widget. The state uses automatic updates and the cursor tracks changes to the linked value.
```cpp
// create state with automatic updates
lager::state optionState;
// connect to one specific subvalue of the state
lager::cursor strength =
optionState[&KisScatterOptionData::curveOption][&KisCurveOptionData::strength];
// read the linked value
strengthSpinBox->setValue(strength.get());
// write the linked value
strength.set(strengthSpinBox->value());
// subscribe to the linked value updates
// (please note that lager also has a way to connect via
// native Qt signals)
strength.bind(std::bind(&QDoubleSpinBox::setValue,
strengthSpinBox,
std::placeholders::_1));
```
--------------------------------
### Return to master branch and update
Source: https://docs.krita.org/en/untranslatable_pages/building/building_krita_on_host_linux_system.html
Switch back to the master branch and pull the latest updates.
```bash
you@yourcomputer:~/kritadev/krita> git checkout master
you@yourcomputer:~/kritadev/krita> git pull
```
--------------------------------
### C++ Code Example
Source: https://docs.krita.org/en/contributors_manual/krita_manual_conventions.html
A C++ function that increments an integer and resets it to 0 if it exceeds 12, with comments.
```cpp
// C++ comment
int myFunction(int i) {
i += 1;
// Check if more than 12
if (i>12) {
i = 0;
}
return i;
}
```
--------------------------------
### Strip metadata with OptiPNG
Source: https://docs.krita.org/en/contributors_manual/optimising_images.html
Strip and compress a PNG file using optipng -strip.
```bash
optipng -strip image.png
```
--------------------------------
### Deactivate the virtual environment
Source: https://docs.krita.org/en/untranslatable_pages/python_coding.html
Exits the currently active virtual environment, returning to the system Python environment.
```bash
deactivate
```