[WASAPI] fix stream types and frequencies enumeration
[xbmc.git] / docs / README.Linux.md
blob3d556df73a3bd5c6baf67415473238380bd51b08
1 ![Kodi Logo](resources/banner_slim.png)
3 # Linux build guide
4 This is the general Linux build guide. Please read it in full before you proceed to familiarize yourself with the build procedure.
6 Several distribution **[specific build guides](README.md)** are available.
8 ## Table of Contents
9 1. **[Document conventions](#1-document-conventions)**
10 2. **[Get the source code](#2-get-the-source-code)**
11 3. **[Install the required packages](#3-install-the-required-packages)**  
12   3.1. **[Build missing dependencies](#31-build-missing-dependencies)**  
13   3.2. **[Enable internal dependencies](#32-enable-internal-dependencies)**
14 4. **[Build Kodi](#4-build-kodi)**  
15   4.1. **[Configure build](#41-configure-build)**  
16   4.2. **[Build](#42-build)**
17 5. **[Build binary add-ons](#5-build-binary-add-ons)**  
18   5.1. **[In-tree building of binary add-ons](#51-in-tree-building-of-binary-add-ons)**  
19   5.2. **[Out-of-tree building of binary add-ons](#52-out-of-tree-building-of-binary-add-ons)**
20 6. **[Run Kodi](#6-run-kodi)**
21 7. **[Uninstall Kodi](#7-uninstall-kodi)**
22 8. **[Test suite](#8-test-suite)**
24 ## 1. Document conventions
25 This guide assumes you are using `terminal`, also known as `console`, `command-line` or simply `cli`. Commands need to be run at the terminal, one at a time and in the provided order.
27 This is a comment that provides context:
28 ```
29 this is a command
30 this is another command
31 and yet another one
32 ```
34 **Example:** Clone Kodi's current master branch:
35 ```
36 git clone https://github.com/xbmc/xbmc kodi
37 ```
39 Commands that contain strings enclosed in angle brackets denote something you need to change to suit your needs.
40 ```
41 git clone -b <branch-name> https://github.com/xbmc/xbmc kodi
42 ```
44 **Example:** Clone Kodi's current Krypton branch:
45 ```
46 git clone -b Krypton https://github.com/xbmc/xbmc kodi
47 ```
49 Several different strategies are used to draw your attention to certain pieces of information. In order of how critical the information is, these items are marked as a note, tip, or warning. For example:
51 > [!NOTE]  
52 > Linux is user friendly... It's just very particular about who its friends are.
54 > [!TIP]
55 > Algorithm is what developers call code they do not want to explain.
57 > [!WARNING]  
58 > Developers don't change light bulbs. It's a hardware problem.
60 **[back to top](#table-of-contents)** | **[back to section top](#1-document-conventions)**
62 ## 2. Get the source code
63 First install the `git` package provided by your distribution. How to do it can be found with a quick search in your favorite search engine.
65 Change to your `home` directory:
66 ```
67 cd $HOME
68 ```
70 Clone Kodi's current master branch:
71 ```
72 git clone https://github.com/xbmc/xbmc kodi
73 ```
75 **[back to top](#table-of-contents)**
77 ## 3. Install the required packages
78 The following is the list of packages that are used to build Kodi on Debian/Ubuntu (with all supported external libraries enabled).
80 > [!NOTE]  
81 > Kodi requires a compiler with C++17 support, i.e. gcc >= 7 or clang >= 5
83 * autoconf, automake, autopoint, gettext, autotools-dev, cmake, curl, default-jre | openjdk-6-jre | openjdk-7-jre, gawk, gcc (>= 7) | gcc-7, g++ (>= 7) | g++-7, cpp (>= 7) | cpp-7, flatbuffers, gdc, gperf, libasound2-dev | libasound-dev, libass-dev (>= 0.9.8), libavahi-client-dev, libavahi-common-dev, libbluetooth-dev, libbluray-dev, libbz2-dev, libcdio-dev, libcec4-dev | libcec-dev, libp8-platform-dev, libcrossguid-dev, libcurl4-openssl-dev | libcurl4-gnutls-dev | libcurl-dev, libcwiid-dev, libdbus-1-dev, libegl1-mesa-dev, libenca-dev, libexiv2-dev, libflac-dev, libfontconfig-dev, libfmt3-dev | libfmt-dev, libfreetype6-dev, libfribidi-dev, libfstrcmp-dev, libgcrypt-dev, libgif-dev (>= 5.0.5), libgles2-mesa-dev [armel] | libgl1-mesa-dev | libgl-dev, libglew-dev, libglu1-mesa-dev | libglu-dev, libgnutls-dev | libgnutls28-dev, libgpg-error-dev, libgtest-dev, libiso9660-dev, libjpeg-dev, liblcms2-dev, liblirc-dev, libltdl-dev, liblzo2-dev, libmicrohttpd-dev, libmysqlclient-dev, libnfs-dev, libogg-dev, libomxil-bellagio-dev [armel], libpcre2-dev, libplist-dev, libpng12-dev | libpng-dev, libpulse-dev, libshairplay-dev, libsmbclient-dev, libspdlog-dev, libsqlite3-dev, libssl-dev, libtag1-dev (>= 1.8) | libtag1x8, libtiff5-dev | libtiff-dev | libtiff4-dev, libtinyxml-dev, libtinyxml2-dev, libtool, libudev-dev, libunistring-dev, libva-dev, libvdpau-dev, libvorbis-dev, libxkbcommon-dev, libxmu-dev, libxrandr-dev, libxslt1-dev | libxslt-dev, libxt-dev, waylandpp-dev | netcat, wayland-protocols | wipe, lsb-release, meson (>= 0.47.0), nasm (>= 2.14), ninja-build, python3-dev, python3-pil | python-imaging, python-support | python3-minimal, rapidjson-dev, swig, unzip, uuid-dev, zip, zlib1g-dev
85 ### 3.1. Build missing dependencies
86 Some packages may be missing or outdated in older distributions. Notably `crossguid`, `libfmt`, `libspdlog`, `waylandpp`, `wayland-protocols`, etc. are known to be outdated or missing. Fortunately there is an easy way to build individual dependencies with **[Kodi's unified depends build system](../tools/depends/README.md)**.
88 Change to Kodi's source code directory:
89 ```
90 cd $HOME/kodi
91 ```
93 Build and install crossguid:
94 ```
95 sudo make -C tools/depends/target/crossguid PREFIX=/usr/local
96 ```
98 Build and install flatbuffers:
99 ```
100 sudo make -C tools/depends/target/flatbuffers PREFIX=/usr/local
103 Build and install libfmt:
105 sudo make -C tools/depends/target/fmt PREFIX=/usr/local
108 Build and install libspdlog:
110 sudo make -C tools/depends/target/spdlog PREFIX=/usr/local
113 Build and install wayland-protocols:
115 sudo make -C tools/depends/target/wayland-protocols PREFIX=/usr/local
118 Build and install waylandpp:
120 sudo make -C tools/depends/target/waylandpp PREFIX=/usr/local
123 > [!WARNING]  
124 > Building `waylandpp` has some dependencies of its own, namely `scons, libwayland-dev (>= 1.11.0) and libwayland-egl1-mesa`
126 > [!TIP]
127 > Complete list of dependencies is available **[here](https://github.com/xbmc/xbmc/tree/master/tools/depends/target)**.
129 ### 3.2. Enable internal dependencies
130 Some dependencies can be configured to build before Kodi. That's the case with `flatbuffers`, `crossguid`, `fmt`, `spdlog`, `rapidjson`, `fstrcmp` and `dav1d`. To enable the internal build of a dependency, append `-DENABLE_INTERNAL_<DEPENDENCY_NAME>=ON` to the configure command below. For example, configuring an X11 build with internal `fmt` would become `cmake ../kodi -DCMAKE_INSTALL_PREFIX=/usr/local -DENABLE_INTERNAL_FMT=ON` instead of `cmake ../kodi -DCMAKE_INSTALL_PREFIX=/usr/local`.
131 Internal dependencies that are based on cmake upstream (currently crossguid, ffmpeg, fmt, spdlog) can have their build type overridden by defining `-D<DEPENDENCY_NAME>_BUILD_TYPE=<buildtype>`. Build Type can be one of `Release, RelWithDebInfo, Debug, MinSizeRel`. eg `-DFFMPEG_BUILD_TYPE=RelWithDebInfo`. If not provided, the build type will be the same as the core Kodi project.
133 > [!NOTE]  
134 > fstrcmp requires libtool
136 ### 3.3. External Dependencies
138 Building with GBM windowing (including `gbm` in the `CORE_PLATFORM_NAME` cmake config) requires `libdisplay-info` for EDID parsing. This is currently a hard dependency for GBM windowing and no internal build option is available. Some distributions may already package it but if not it is available to build from source here: https://gitlab.freedesktop.org/emersion/libdisplay-info
140 **[back to top](#table-of-contents)** | **[back to section top](#3-install-the-required-packages)**
142 ## 4. Build Kodi
143 ### 4.1. Configure build
144 If you get a `Could NOT find...` error message during CMake configuration step, take a note of the missing dependencies and either install them from repositories (if available) or **[build the missing dependencies manually](#31-build-missing-dependencies)**.
146 Create an out-of-source build directory:
148 mkdir $HOME/kodi-build
151 > [!TIP]
152 > Look for comments starting with `Or ...` and only execute the command(s) you need.
154 Change to build directory:
156 cd $HOME/kodi-build
159 Configure build for X11:
161 cmake ../kodi -DCMAKE_INSTALL_PREFIX=/usr/local -DCORE_PLATFORM_NAME=x11 -DAPP_RENDER_SYSTEM=gl
164 > [!NOTE]  
165 > You can use `gles` instead of `gl` if you want to build with `GLES`.
167 Or configure build for Wayland:
169 cmake ../kodi -DCMAKE_INSTALL_PREFIX=/usr/local -DCORE_PLATFORM_NAME=wayland -DAPP_RENDER_SYSTEM=gl
172 > [!NOTE]  
173 > You can use `gles` instead of `gl` if you want to build with `GLES`.
175 Or configure build for GBM:
177 cmake ../kodi -DCMAKE_INSTALL_PREFIX=/usr/local -DCORE_PLATFORM_NAME=gbm -DAPP_RENDER_SYSTEM=gles
180 > [!NOTE]  
181 > You can use `gl` instead of `gles` if you want to build with `GL`.
183 Or configure build with any combination of the three (default is "x11 wayland gbm"):
185 cmake ../kodi -DCMAKE_INSTALL_PREFIX=/usr/local -DCORE_PLATFORM_NAME="x11 wayland gbm" -DAPP_RENDER_SYSTEM=gl
188 > [!NOTE]  
189 > You can use `gles` instead of `gl` if you want to build with `GLES`.
191 > [!NOTE]  
192 > You can use several alternative linkers if available on your system: gnu gold (default), llvm lld or mold
194 To use an alternative linker, enable it with `-DENABLE_GOLD=ON` or `-DENABLE_LLD=ON` or `-DENABLE_MOLD=ON`
197 ### 4.2. Build
199 cmake --build . -- VERBOSE=1 -j$(getconf _NPROCESSORS_ONLN)
202 > [!TIP]
203 > By adding `-j<number>` to the make command, you can choose how many concurrent jobs will be used and expedite the build process. It is recommended to use `-j$(getconf _NPROCESSORS_ONLN)` to compile on all available processor cores. The build machine can also be configured to do this automatically by adding `export MAKEFLAGS="-j$(getconf _NPROCESSORS_ONLN)"` to your shell config (e.g. `~/.bashrc`).
205 After the build process completes successfully you can test your shiny new Kodi build while in the build directory:
207 ./kodi-x11
210 Or if you built for Wayland:
212 ./kodi-wayland
215 Or if you built for GBM:
217 ./kodi-gbm
220 > [!WARNING]  
221 > User running `kodi-gbm` needs to be part of `input` and `video` groups. Otherwise you'll have to use `sudo`.
223 Add user to input and video groups:
225 sudo usermod -a -G input,video <username>
228 You will need to log out and log back in to see the new groups added to your user. Check groups your user belongs to with:
230 groups
233 If everything was OK during your test you can now install the binaries to their place, in this example */usr/local*.
235 sudo make install
238 This will install Kodi in the prefix provided in **[section 4.1](#41-configure-build)**.
240 > [!TIP]
241 > To override Kodi's install location, use `DESTDIR=<path>`. For example:
244 sudo make install DESTDIR=$HOME/kodi
247 **[back to top](#table-of-contents)** | **[back to section top](#4-build-kodi)**
249 ## 5. Build binary add-ons
250 You can find a complete list of available binary add-ons **[here](https://github.com/xbmc/repo-binary-addons)**.
252 In the following, two approaches to building binary add-ons are described.
253 While the workflow of in-tree building is more automated,
254 it is only supported as long as `-DCMAKE_INSTALL_PREFIX=/usr/local` is not changed from it's default of `/usr/local`.
255 Thus when changing `DCMAKE_INSTALL_PREFIX`, you must follow the out-of-tree building instructions.
257 ### 5.1. In-tree building of binary add-ons
259 Change to Kodi's source code directory:
261 cd $HOME/kodi
264 Build all add-ons:
266 sudo make -j$(getconf _NPROCESSORS_ONLN) -C tools/depends/target/binary-addons PREFIX=/usr/local
269 Build specific add-ons:
271 sudo make -j$(getconf _NPROCESSORS_ONLN) -C tools/depends/target/binary-addons PREFIX=/usr/local ADDONS="audioencoder.flac pvr.vdr.vnsi audiodecoder.snesapu"
274 Build a specific group of add-ons:
276 sudo make -j$(getconf _NPROCESSORS_ONLN) -C tools/depends/target/binary-addons PREFIX=/usr/local ADDONS="pvr.*"
279 Clean-up binary add-ons:
281 sudo make -C tools/depends/target/binary-addons clean
284 For additional information on regular expression usage for ADDONS_TO_BUILD, view ADDONS_TO_BUILD section located here [Kodi add-ons CMake based buildsystem](../cmake/addons/README.md)
286 > [!NOTE]  
287 > `PREFIX=/usr/local` should match Kodi's `-DCMAKE_INSTALL_PREFIX=` prefix used in **[section 4.1](#41-configure-build)**.
289 **[back to top](#table-of-contents)**
292 ### 5.2. Out-of-tree building of binary add-ons
294 You can find a complete list of available binary add-ons **[here](https://github.com/xbmc/repo-binary-addons)**.
295 Exemplary, to install `pvr.demo`, follow below steps.
296 For other addons, simply adapt the repository based on the information found in the `.txt` associated with the respective addon **[here](https://github.com/xbmc/repo-binary-addons)**
298 Some addons have dependencies.
299 You must install all required dependencies of an addon before installing the addon.
300 Required dependencies can be found by checking the `depends` folder and
301 it's subdirectories in the repository of the respective addons.
303 A number of addons require the the `p8-platform` and `kodi-platform` add-ons.
304 Note that dependencies on `p8-platform` and `kodi-platform` are typically not declared in the `depends` folder.
305 They are only declared in the `CMakeLists.txt` file of the respective addon (e.g. via `find_package(p8-platform REQUIRED)`).
306 Below we demonstrate how to build these two.
307 First, the platform addon:
310 cd ~/src/
311 git clone https://github.com/xbmc/platform.git
312 cd ~/src/platform/
313 cmake -DCMAKE_INSTALL_PREFIX=/usr/local
314 make && make install
317 Then the kodi-platform add-on:
320 cd ~/src/
321 git clone https://github.com/xbmc/kodi-platform.git
322 cd ~/src/kodi-platform/
323 cmake -DCMAKE_INSTALL_PREFIX=/usr/local
324 make && make install
327 Finally, to install pvr.demo
330 cd ~/src
331 git clone https://github.com/kodi-pvr/pvr.demo.git
332 cd ~/src/pvr.demo/
333 cmake -DCMAKE_INSTALL_PREFIX=/usr/local
334 make && make install
337 > [!NOTE]  
338 > `-DCMAKE_INSTALL_PREFIX=` should match Kodi's `-DCMAKE_INSTALL_PREFIX=` prefix used in **[section 4.1](#41-configure-build)**.
340 ## 6. Run Kodi
341 If you chose to install Kodi using `/usr` or `/usr/local` as the `-DCMAKE_INSTALL_PREFIX=`, you can just issue *kodi* in a terminal session.
343 If you changed `-DCMAKE_INSTALL_PREFIX=` to install Kodi into some non-standard location, you will have to run Kodi directly:
345 <CMAKE_INSTALL_PREFIX>/bin/kodi
348 To run Kodi in *portable* mode (useful for testing):
350 <CMAKE_INSTALL_PREFIX>/bin/kodi -p
353 **[back to top](#table-of-contents)**
355 ## 7. Uninstall Kodi
357 sudo make uninstall
360 > [!WARNING]  
361 > If you reran CMakes' configure step with a different `-DCMAKE_INSTALL_PREFIX=`, you will need to rerun configure with the correct path for this step to work correctly.
363 If you would like to also remove any settings and third-party addons (skins, scripts, etc.) and Kodi configuration files, you should also run:
365 rm -rf ~/.kodi
368 **[back to top](#table-of-contents)**
370 ## 8. Test suite
371 Kodi has a test suite which uses the Google C++ Testing Framework. This framework is provided directly in Kodi's source tree.
373 Build and run Kodi's test suite:
375 make check
378 Build Kodi's test suite without running it:
380 make kodi-test
383 Run Kodi's test suite manually:
385 ./kodi-test
388 Show Kodi's test suite *help* notes:
390 ./kodi-test --gtest_help
393 Useful options:
395 --gtest_list_tests
396   List the names of all tests instead of running them.
397   The name of TEST(Foo, Bar) is "Foo.Bar".
399 --gtest_filter=POSITIVE_PATTERNS[-NEGATIVE_PATTERNS]
400   Run only the tests whose name matches one of the positive patterns but
401   none of the negative patterns. '?' matches any single character; '*'
402   matches any substring; ':' separates two patterns.
405 **[back to top](#table-of-contents)**