Warning, /multimedia/kdenlive/dev-docs/build.md is written in an unsupported language. File is not indexed.

0001 # Building Kdenlive
0002 
0003 ## Supported platforms
0004 
0005 Kdenlive is primarily developed on GNU/Linux, but it is also possible to [build Kdenlive on Microsoft Windows and macOS using Craft](#build-craft). For Windows also [other possibilities exist](https://community.kde.org/Kdenlive/Development/WindowsBuild). 
0006 
0007 Currently supported distributions are:
0008 
0009 * Ubuntu 22.04 LTS Focal Fossa and derivatives
0010 * Arch Linux
0011 
0012 But you should be able to build it on any platform that provides up-to-date versions of the following dependencies: Qt >= 5.15.2, KF5 >= 5.86, MLT >= 7.10.0.
0013 
0014 ## Build on Linux
0015 
0016 ### Base procedure
0017 
0018 Kdenlive usually requires the latest version of MLT, in which go several API updates, bugfixes and optimizations.
0019 On Ubuntu, the easiest way is to add [Kdenlive's ppa](https://launchpad.net/~kdenlive/+archive/ubuntu/kdenlive-master)
0020 
0021 ```bash
0022 sudo add-apt-repository ppa:kdenlive/kdenlive-master
0023 sudo apt update
0024 ```
0025 
0026 It is recommended to uninstall the official kdenlive packages to avoid potential conflicts. 
0027 
0028 ```bash
0029 sudo apt remove kdenlive kdenlive-data
0030 ```
0031 
0032 
0033 #### Get the build dependencies
0034 
0035 
0036 First, make sure you have the required tooling installed:
0037 
0038 ```bash
0039 sudo apt install build-essential git cmake extra-cmake-modules libsm-dev
0040 ```
0041 
0042 You can use your distribution packages information (if not too old) to easily get a complete build environment:
0043 
0044 ```bash
0045 # Debian/Ubuntu -- Enable deb-src entries /etc/apt/sources beforehand
0046 sudo apt build-dep mlt kdenlive
0047 # Fedora/CentOS -- Install builddep beforehand
0048 dnf builddep mlt kdenlive
0049 # OpenSUSE
0050 zypper source-install --build-deps-only mlt kdenlive
0051 ```
0052 Or install the dependencies explicitly:
0053 
0054 ```bash
0055 # KDE Frameworks 5, based on Qt5
0056 sudo apt install libkf5archive-dev libkf5bookmarks-dev libkf5coreaddons-dev libkf5config-dev \
0057 libkf5configwidgets-dev libkf5dbusaddons-dev libkf5kio-dev libkf5widgetsaddons-dev \
0058 libkf5notifyconfig-dev libkf5newstuff-dev libkf5xmlgui-dev libkf5declarative-dev \
0059 libkf5notifications-dev libkf5guiaddons-dev libkf5textwidgets-dev libkf5purpose-dev \
0060 libkf5iconthemes-dev libkf5crash-dev libkf5filemetadata-dev libkf5codecs-dev kio \
0061 kinit qtdeclarative5-dev libqt5svg5-dev qml-module-qtquick-controls libqt5networkauth5-dev \
0062 qtmultimedia5-dev qtquickcontrols2-5-dev qttools5-dev breeze-icon-theme breeze
0063 
0064 # Multimedia stack
0065 sudo apt install frei0r-plugins ffmpeg
0066 
0067 # MLT, except if you want to build it manually 
0068 sudo apt install libmlt++-dev libmlt-dev melt
0069 
0070 # Dependencies for localization
0071 sudo apt install ruby subversion gnupg2 gettext
0072 
0073 
0074 ```
0075 #### Clone the repositories
0076 
0077 In your development directory, run:
0078 
0079 ```bash
0080 git clone https://invent.kde.org/multimedia/kdenlive.git
0081 ```
0082 
0083 And if you want to build MLT manually:
0084 
0085 ```bash
0086 git clone https://github.com/mltframework/mlt.git
0087 
0088 # Install MLT dependencies
0089 sudo apt install libxml++2.6-dev libavformat-dev libswscale-dev libavfilter-dev libavutil-dev libavdevice-dev libsdl1.2-dev librtaudio-dev libsox-dev libsamplerate0-dev librubberband-dev libebur128-dev
0090 ```
0091 
0092 #### Build and install the projects
0093 
0094 You should decide where you want to install your builds:
0095 
0096 - by default it goes to `/usr/local` (good option if you are admin of the machine, normally programs there are automatically detected);
0097 - you may use `$HOME/.local` user-writable directory (good option if you don't want to play with admin rights, programs there are also usually found)
0098 - you may want to override the distribution files in `/usr` (then you have to remove MLT & Kdenlive binary & data packages first)
0099 - you can pick any destination you like (eg in `/opt` or anywhere in `$HOME`, then you will have to set several environment variables for programs, libs and data to be found)
0100 
0101 Let's define that destination as `INSTALL_PREFIX` variable; also you can set `JOBS` variable to the number of threads your CPU can offer for builds.
0102 
0103 And build the dependencies (MLT) before the project (Kdenlive):
0104 
0105 ```bash
0106 INSTALL_PREFIX=$HOME/.local # or any other choice, the easiest would be to leave it empty ("")
0107 JOBS=4
0108 
0109 # Only if you want to compile MLT manually
0110 cd mlt
0111 mkdir build && cd build
0112 cmake .. -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX
0113 make -j$JOBS
0114 make install
0115 # 'sudo make install' if INSTALL_PREFIX is not user-writable
0116 
0117 # Kdenlive
0118 cd ../../kdenlive
0119 mkdir build && cd build
0120 # Even if you specified a user-writable INSTALL_PREFIX, some Qt plugins like the MLT thumbnailer are
0121 # going be installed in non-user-writable system paths to make them work. If you really do not want
0122 # to give root privileges, you need to set KDE_INSTALL_USE_QT_SYS_PATHS to OFF in the line below.
0123 cmake .. -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX -DKDE_INSTALL_USE_QT_SYS_PATHS=ON -DRELEASE_BUILD=OFF
0124 ```
0125 
0126 ```bash
0127 make -j$JOBS
0128 make install
0129 # 'sudo make install' if INSTALL_PREFIX is not user-writable or if KDE_INSTALL_USE_QT_SYS_PATHS=ON
0130 ```
0131 
0132 Note that `make install` is required for Kdenlive, otherwise the effects will not be installed and cannot be used.
0133 
0134 #### Run Kdenlive
0135 
0136 If you didn't build in a system path in which all libs and data are automatically found, you will need to set environment variables to point to them.
0137 This is done by the auto-generated script in `kdenlive/build` that must be sourced (to keep variables set in current shell, unlike just executing the script):
0138 
0139 ```bash
0140 . prefix.sh
0141 kdenlive
0142 ```
0143 
0144 ## <a name="build-craft">Build with KDE Craft (Linux, Windows, macOS)</a>
0145 
0146 [Craft](https://community.kde.org/Craft) is a tool to build the sources and its third-party requirements. It is an easy way to build software, but however not ideal if you want to build Kdenlive for development purposes.
0147 
0148 1. Set up Craft as described [here](https://community.kde.org/Craft#Setting_up_Craft). (On Windows choose MinGW as compiler!)
0149 2. Start building kdenlive. You can simply run `craft --target=master kdenlive`
0150 3. Within the the craft environment you can running Kdenlive is as simple as `kdenlive`
0151 
0152 _Notes for Craft on macOS with arm M1 chip_: currently (april 2022), Craft doesn't support arm toolchain to compile. Therefore, you must compile in x84_64 mode. To do this, before launching craft using the ```craftenv.sh``` script, you must enter the following command:
0153 ```
0154 arch -arch x86_64 zsh -li
0155 ```
0156 After this you can follow the standard Craft procedure to compile Kdenlive.
0157 
0158 ### Tips for Craft
0159 
0160 * If you want to compile kdenlive in debug mode, you can do so by running `craft --buildtype Debug kdenlive`
0161 * If you want to compile the stable version instead of the master with that last changes, remove `--target=master` from the craft command: `craft kdenlive`
0162 * With Craft you can also easily package Kdenlive as `.dmg`, `.exe` or `.appimage` (depending on your platform): `craft --target=master --package kdenlive` The output can be found in `CraftRoot/tmp`
0163 * For more instructions and tipps on Craft see https://community.kde.org/Craft
0164 
0165 ## Various development tricks
0166 
0167 ### Debugging
0168 
0169 Having debug symbols helps getting much more useful information from crash logs or analyzers outputs; this is enabled at configure stage.
0170 - append `-DCMAKE_BUILD_TYPE=Debug` to `cmake` line of kdenlive and/or mlt
0171 
0172 
0173 ### Running tests
0174 
0175 Kdenlive test coverage is focused mostly on timeline model code (extending tests to more parts is highly desired). To run those tests, append to `cmake` line:
0176 `-DBUILD_TESTING=ON`
0177 
0178 ### Fuzzer
0179 
0180 Kdenlive embeds a fuzzing engine that can detect crashes and auto-generate tests. It requires to have clang installed (generally in `/usr/bin/clang++`). This can be activated in `cmake` line with:
0181 `-DBUILD_FUZZING=ON -DCMAKE_CXX_COMPILER=/usr/bin/clang++`
0182 
0183 To learn more fuzzing especially in the context of Kdenlive read this [blog post][fuzzer-blog].
0184 
0185 ### Help file for QtCreator, KDevelop, etc.
0186 
0187 You can automatically build and install a `*.qch` file with the doxygen docs about the source code to use it with your IDE like Qt Assistant, Qt Creator or KDevelop. This can be activated in `cmake` line with:
0188 `-DBUILD_QCH=ON`
0189 
0190 You can find the `kdenlive.qch` at `build/src` and after `make install` at `${CMAKE_INSTALL_PREFIX}/lib/cmake/kdenlive`
0191 
0192 To add the `kdenlive.qch` file to Qt Creator, select **Tools** > **Options** > **Help** > **Documentation** > **Add**.
0193 
0194 ### Speeding up compilations
0195 
0196 Ninja build systems, compared to make, seems faster and better detecting which files are necessary to rebuild. You can enable it appending `-GNinja` to `cmake` line
0197 CCache also helps: `-DCMAKE_CXX_COMPILER_LAUNCHER=ccache`
0198 
0199 ### Analyzers
0200 
0201 You can configure Kdenlive to embed tooling for runtime analysis, for example appending to cmake line:
0202 `-DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DECM_ENABLE_SANITIZERS='address'`
0203 
0204 This one will report in terminal all memory handling errors found during execution.
0205 
0206 ### Building OpenCV tracking module
0207 
0208 MLT/Kdenlive tracking effect relies on a "contrib" a OpenCV module that is not shipped by distributions.
0209 We build it in our AppImage but you may want it on your system (note OpenCV deserves its reputation of being difficult to build!).
0210 
0211 ```bash
0212 wget https://github.com/opencv/opencv/archive/4.5.5.tar.gz -O opencv-4.5.5.tar.gz
0213 wget https://github.com/opencv/opencv_contrib/archive/4.5.5.tar.gz -O opencv_contrib-4.5.5.tar.gz
0214 tar xaf opencv-4.5.5.tar.gz
0215 tar xaf opencv_contrib-4.5.5.tar.gz
0216 cd opencv-4.5.5
0217 mkdir build
0218 cd build
0219 # Important: if want to install to the default location
0220 # (ie. you left INSTALL_PREFIX empty in the previous step where we configured it)
0221 # remove -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX from the next command!
0222 cmake .. -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX \
0223   -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.5.5/modules \
0224   -DOPENCV_GENERATE_PKGCONFIG=ON -DBUILD_LIST=tracking -DOPENCV_BUILD_3RDPARTY_LIBS=OFF
0225 make install
0226 ```
0227 
0228 Then you will have to rebuild MLT appending `-DMOD_OPENCV=ON` to `cmake` line!
0229 
0230 ### Building frei0r
0231 
0232 You may be interested in building latest frei0r effects library. So get dependencies, clone repository, and build-install:
0233 
0234 ```bash
0235 sudo apt build-dep frei0r
0236 git clone https://github.com/dyne/frei0r.git
0237 cd frei0r
0238 mkdir build
0239 cd build
0240 cmake .. -DWITHOUT_OPENCV=true -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX
0241 ```
0242 
0243 Note: as of 20.04, frei0r doesn't support recent OpenCV (and effects using it seemed not very stable)
0244 
0245 ### Building in Docker
0246 
0247 It is possible to run the above commands inside a container, with a fresh Ubuntu for example.
0248 Note that Kdenlive cannot be easily run from inside the Docker container as it is a GUI application.
0249 
0250 ```bash
0251 # Spin up a Docker container
0252 # The --rm flag removes the container after it is stopped.
0253 docker run -it --rm ubuntu:22.04
0254 
0255 # Now install the dependencies etc.
0256 # Note that you are root in the container, and sudo neither exists nor works.
0257 apt install …
0258 
0259 # When you are done, exit
0260 exit
0261 ```
0262 
0263 ## Translating Kdenlive
0264 
0265 TODO
0266 
0267 [fuzzer-blog]: https://kdenlive.org/en/2019/03/inside-kdenlive-how-to-fuzz-a-complex-gui-application/