Not so long time ago qBittorrent (master branch) has started to require Qt 6.5, but unfortunately, it is available only in few Linux distros nowadays. Most Debian- or Ubuntu-based system don't have suitable Qt version in their repositories, so to get the latest qBittorrent sources to build, you have to build Qt. In general, building Qt in Linux environment is not a complex task, but what is complex in this process is installing the right dependencies. Qt has a lot of external dependencies (especially for widgets part), and most of them are optional, so you have to know what you need from Qt and what dependency to install to get that feature. And this may be hard, and why many users who tried to build Qt faced various issues (not during Qt build process, only afterward, when tried to use self-compiled Qt).
This guide is focused mostly on Qt build process (more correctly even on just required dependencies), as so as this is the most complex part, the rest if pretty straightforward for anyone who familiar with CMake, even if completely not familiar with qBittorrent and libtorrent.
This guide is not supposed to be full (covering all possible cases) or minimal (in any sense of this word), it is focused on simplicity, so only really important options are mentioned. No cross-compilation case is covered, only build for host architecture.
It doesn't cover any "upgrade" scenarios, i.e. dependency or qBittorrent itself version change. This is just a build guide, any automation tasks are out of scope.
Debian-based environment (e.g. Debian, Ubuntu, Linux Mint) is assumed, package names used here are only applicable to Debian-based systems. It was written and tested on Ubuntu 22.04, which was "reasonable minimum" at the time of writing.
Anything described here is only applicable to qBittorrent versions with Qt 6 support, no old versions are covered. qBittorrent GUI version is built through the guide, if you want to build daemon (aka "nox" version) you need to adjust corresponding build options (not covered in this guide, refer to qBittorrent documentation or whatever sources).
This guide describes how to build static versions of Qt and libtorrent, and finally use them to build qBittorrent, no shared libraries build process is covered. This is intentional, as so as significantly simplifies runtime setup (nothing required at all).
Also this document may be interesting for anyone wanting to build Qt for their own app, Qt build process covered here is suitable for many applications, and demonstrates how to get some "missing" Qt parts (which may be required for some application) easily.
Any user interested in building qBittorrent from sources (doesn't matter master branch or any recent release) can find something useful here, or at least some hints where to start.
Advanced users familiar with C/C++ sources build process using CMake or anyone wanting to play with qBittorrent sources also may benefit from this guide.
This document doesn't require any special skills or knowledge, the only thing is just need to be comfortable with command line. It is enough just to follow it to get working qBittorrent (GUI) compiled from sources.
First of all, please check if curl
is installed in your system, if not - please install it, as so as it will be used many times through the guide to download whatever sources. Advanced users may use whatever else tool (for example wget
) for this, but corresponding options must be adjusted.
Moreover, this guide doesn't use git
at all, even regardless it is focused on building qBittorrent master branch. This is also intentional, just to demonstrate some alternative methods.
Please note, pretty much disk space is required to complete the build - about 10 GB. Most of it used by Qt's intermediate binaries. So, please make sure that you have enough free space.
Only few build tools are required: C++ compiler itself (only GCC is covered here), CMake, and Ninja build system (it is at least strongly recommended by Qt, but maybe required nowadays, and also commonly used by any CMake-based projects). Install the next packages to get these mentioned tools in your system:
sudo apt install g++ cmake ninja-build
There are few common dependencies used by Qt, libttorrent, and qBittorrent. And fortunately, versions available in repositories are suitable for qBittorrent. These dependencies are OpenSSL and Zlib. OpenSSL provides a lot of cryptographic stuff often used to establish secure connection (HTTPS and so on). Zlib is general-purpose compression library, historically came from PNG. Install next packages to get these libraries:
sudo apt install libssl-dev zlib1g-dev
qBittorrent requires few more dependencies: Boost C++ Libraries, Qt, and libtorrent (it also requires Boost). All these dependencies will be downloaded and built through the guide, the order can be arbitrary, not only as shown in this guide.
As this guide is mostly focused on Qt, so it is built first, but again, this is not strictly necessary.
It worth to write few words about directory structure used through the guide. You are not obliged to use the same, but in that case you need to adjust corresponding paths (paths will appear in many places in this guide).
Any directory writable for current user can be used as working directory (actually $HOME
was used during this guide creation, but this is not strictly necessary and no paths refer to this). The following directory structure is created and used through the guide:
qbt <--- the most top-level directory, you will not go outside it through the guide
|- qt <--- Qt sources and intermediate binaries live here
| |- qtbase-6.5.2 <--- one of Qt sources directories
| |- build-base <--- one of Qt components build directories
| |- ... <--- few more similary named directories
|
|- libtorrent-rasterbar-2.0.9 <--- libtorrent sources
|- build-lt <--- libtorrent binaries
|- qBittorrent-master <--- qBittorrent sources
|- build-qbt <--- qBittorrent binaries
All directories are created through the guide. The only one need to be created before all steps is the topmost one (qbt
):
mkdir qbt && cd $_
The following sections assume that you are in qbt
directory if anything is not stated.
This guide uses a bit unusual way to get Qt sources, all of them will be placed under qt
directory, so create it first and move to it:
mkdir qt && cd $_
The rest of commands in this section assume that you are in qt
directory.
It is not strictly required to clone Qt repository (with few submodules) to get its sources, Qt modules can be used instead. This is done just to save bandwidth - download only ~60 MB instead of 700+ MB in case of git clone
, also to demonstrate the alternative way of getting Qt sources. They can be downloaded from Qt releases archive, but it seems to be more reliable to download the same content from Qt repositories GitHub mirror:
curl -L 'https://github.com/qt/qtbase/archive/v6.5.2.tar.gz' | tar xz
curl -L 'https://github.com/qt/qtsvg/archive/v6.5.2.tar.gz' | tar xz
curl -L 'https://github.com/qt/qttools/archive/v6.5.2.tar.gz' | tar xz
curl -L 'https://github.com/qt/qttranslations/archive/v6.5.2.tar.gz' | tar xz
Commands above utilize some GitHub feature which on the fly provides archive from repository at specific commit/tag, and then that archive is extracted also on the fly. It works only due to used archive format nature, not all archive formats or tools support this.
The hardest part in Qt build process is installing all required dependencies. This guide covers pretty generic case suitable for a lot of GUI apps, but only for X11. If you need/want Qt for Wayland, you must build it by yourself (there are no any hints in this guide regarding this). Application built with this Qt will work in Wayland environment, just through XWayland (never saw not installed by default).
This dependency list is pretty minimalist and reasonable to cover generic case. It mostly contains X11 dependencies (unfortunately, there are no any metapackage to install them all at once, you have to enumerate them one by one), only few other very common libraries are listed in it:
sudo apt install libdbus-1-dev libxkbcommon-dev libxkbcommon-x11-dev libfontconfig-dev libxcb-util0-dev libxcb-randr0-dev libxcb-render0-dev libxcb-render-util0-dev libxcb-shape0-dev libxcb-shm0-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb-cursor-dev libxcb-image0-dev libxcb-icccm4-dev libxcb-keysyms1-dev libx11-dev libx11-xcb-dev libxext-dev libxrender-dev libxcomposite-dev libfreetype-dev libgl-dev
Some notes about few listed dependencies and why they are important:
libdbus-1-dev
- D-Bus inter-process communication mechanism, used by many different systems in Linux. qBittorrent, for example, uses it for power management (directly) and sending notifications (indirectly).libfontconfig-dev
+libfreetype-dev
- fonts enumeration and renderinglibgl-dev
- access to desktop OpenGL implementation. In Linux everything is rendered using OpenGL, at least on X11.
All these packages are required to build Qt usable for GUI application, it can be successfully built without many of them, but you will be unable to run GUI application (but it will be also compiled successfully in many cases), so, be careful.
Build Qt module-by-module starting with base, as so as it is required by any other modules. In this guide only strictly required options are shown, the rest have default values determined by Qt build system. Most of options are self-explanatory, but additional comments for some of them are still left below. Qt will be installed into /usr/local/Qt-<version>
, so root privileges are required. This will not harm you system as so as nothing uses looks into such directories, even more, there are no shared libraries as so as Qt is built as static library.
Use next commands to build all already downloaded Qt modules inside qt
folder:
# Qt build (qtbase)
mkdir build-base
cd build-base/
../qtbase-6.5.2/configure -release -static
cmake --build . --parallel
sudo cmake --install .
cd ..
# Qt build (qtsvg)
mkdir build-svg
cd build-svg/
/usr/local/Qt-6.5.2/bin/qt-configure-module ../qtsvg-6.5.2/
cmake --build .
sudo cmake --install .
cd ..
# Qt build (qttools)
mkdir build-tools
cd build-tools/
/usr/local/Qt-6.5.2/bin/qt-configure-module ../qttools-6.5.2/ -no-feature-assistant
cmake --build .
sudo cmake --install .
cd ..
# Qt build (qttranslations)
mkdir build-translations
cd build-translations/
/usr/local/Qt-6.5.2/bin/qt-configure-module ../qttranslations-6.5.2/
cmake --build .
sudo cmake --install .
cd ../..
-no-feature-assistant
option disables build of Qt Assistant tool (documentation browser). We do not build documentation, so the tool is not required, but what more important, it requires some external dependency, which is not listed in the list above, so it even can't be built.
All mentioned options can be passed at once to top-level configure script if you are using Qt super module repo instead of separate modules.
Build process will take some time, especially noticeable for qtbase (expected, there are most of Qt sources). That's all for Qt. As result, you will get /usr/local/Qt-6.5.2
folder with all files necessary for application compilation.
Another dependency is Boost C++ Libraries. It is used by both libtorrent and qBittorrent itself. The library is huge, but fortunately, used parts are header-only nowadays, so nothing must be built, only download is required.
We have to use custom downloaded library instead of provided by system as so as qBittorrent requires newer version rather than available in repositories.
curl -L 'https://boostorg.jfrog.io/artifactory/main/release/1.83.0/source/boost_1_83_0.tar.bz2' | tar xj
The same trick as for Qt is used here, but just without GitHub part.
Please don't use Boost from git repository unless you know what are you doing. Boost from git repository requires some additional preparation steps before usage, and this may be tricky.
The heart of qBittorrent is libtorrent library. At the time of writing, qBittorrent can be build with any of supported mainstream versions (1.2.x and 2.0.x). 2.0.x version is used in this guide, but 1.2.x can be built with exactly the same build options.
There is the only note about sources downloading difference between 1.2 and 2.0 versions - 2.0 version contains some submodules in repository and they are not downloaded using the trick with archive, so release sources archive should be downloaded instead.
As we are using custom Boost library, it is reasonable to build libtorrent with it, just to avoid any possible incompatibility issues. Also, qBittorrent master branch usually requires latest available libtorrent versions, what is very often not true when it comes to distro repositories, so build is usually necessary.
libtorrent uses CMake build system, so it can be built as any other CMake-based project. For the sake of simplicity, only few options are specified. The final step installs libtorrent into /usr/local
(default path as no option was specified). This is will not interfere anything, as so as libtorrent is built as static library. Also this simplifies include/library search process, no options regarding this are required, as so as used path is "system visible".
curl -L 'https://github.com/arvidn/libtorrent/releases/download/v2.0.9/libtorrent-rasterbar-2.0.9.tar.gz' | tar xz
cmake -G Ninja -S libtorrent-rasterbar-2.0.9/ -B build-lt -D CMAKE_PREFIX_PATH="$PWD/boost_1_83_0" -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=OFF
cmake --build build-lt/
sudo cmake --install build-lt/
-S
and -B
options are used just to make configure step single (without creating directory and moving into it) and simplify the path to Boost library (as so as it is on the same level).
$PWD
is used because usually CMake "doesn't like" relative paths in "prefix paths", so also use absolute path if you specify some other path comparing to this guide.
Now everything is ready and time to build qBittorrent. This guide uses qBittorrent sources from master branch, but some other version with Qt 6 support can be used here (in that case you need to specify -D QT6=ON
additionally).
The following lines will download qBittorrent sources from official GitHub repository using master branch as version. GUI version with all default options values will be compiled. Adjust depending on your needs or preferences. As last step, qBittorrent is also installed into the system (again, into /usr/local
, as no other path was specified).
curl -L 'https://github.com/qbittorrent/qBittorrent/archive/master.tar.gz' | tar xz
cmake -G Ninja -S qBittorrent-master/ -B build-qbt -D CMAKE_PREFIX_PATH="$PWD/boost_1_83_0;/usr/local/Qt-6.5.2" -D CMAKE_BUILD_TYPE=Release
cmake --build build-qbt/
sudo cmake --install build-qbt/
Installation into /usr/local
solves/simplifies several cases related to "system integration" (aka association with .torrent files and magnet links handling, also few more very subtle things mostly noticeable in KDE).
This guide is appeared as result of some questions from users tried to build Qt 6 and faced various problems, and supposed to be as temporary solution until new enough Qt appear in most Linux distros. Than this document very likely will be deleted as non-needed, because official qBittorrent documentation describes the way to build qBittorrent using dependencies from system packages.