Skip to content

Compiling qBittorrent nox 4.x on DietPi or Raspbian (Debian 9.0) for ARM devices

Millichrome edited this page Mar 13, 2019 · 5 revisions

Raspbian is the most popular Linux distribution built for Raspberry Pi hardware.

DietPi is a refined Linux distribution for ARM SoCs such as Raspberry Pi 3 B+ and ASUS Tinker Board.

Both are based on Debian. Debian 9.0 ships with a patched version of an older qBittorrent-nox release (3.3.7). qBittorrent 4.x has many improvements to the webUI component which are of particular use for headless operation.

This guide outlines the steps needed to compile qBittorrent-nox 4.1.x and run it as a service.

This guide was made possible by the authors of the Debian/Ubuntu compilation guide and Guide on running qBittorrent as a service. A few DietPi-specific amendments are included.

Table of Contents

Dependencies

You will first need to install various tools and libraries needed for compilation.

sudo apt-get install \
    build-essential \
    pkg-config \
    automake \
    libtool \
    libc6-dev \
    libboost-dev \
    libboost-system-dev \
    libboost-chrono-dev \
    libboost-random-dev \
    libssl-dev \
    qtbase5-dev \
    qttools5-dev-tools \
    libqt5svg5-dev \
    zlib1g-dev

If you choose to retrieve source code using git clone then also sudo apt-get install git.

Compiling Libtorrent

DietPi's repositories include an older version of Libtorrent. You will need to compile Libtorrent 1.1.x to get qBittorrent-nox 4.x running.

To get the Libtorrent 1.1.x source code, either

A. git clone ...

B. wget ...

A. git clone from repository

git clone https://github.com/arvidn/libtorrent.git
cd libtorrent
# select the latest release tag
git checkout $(git tag | grep libtorrent-1_1_ | sort -t _ -n -k 3 | tail -n 1)

B. download the latest release

using release libtorrent_1_2_0 in this example

wget https://github.com/arvidn/libtorrent/archive/libtorrent_1_2_0.zip
unzip libtorrent_1_2_0.zip
cd libtorrent-libtorrent_1_2_0

Compile Libtorrent 1.1.x

./autotool.sh
export CXXFLAGS=-std=c++11
./configure \
    --disable-debug \
    --enable-encryption \
    --with-boost-libdir=/usr/lib/arm-linux-gnueabihf 
    --with-libiconv
make -j$(nproc)
sudo make install

out of memory (OOM)

If OOM errors occur then add a swap file.

sudo dd if=/dev/zero of=/.swapfile bs=1M count=1024
sudo mkswap /.swapfile
sudo swapon /.swapfile
sudo swapon -s  # check swap is activated
make
# assuming the prior command succeeded
sudo swapoff /.swapfile
sudo rm /.swapfile

(Those commands were copied from here).

One example manifestation of an OOM error on Raspbian OS looks like

$ make
...
make[1]: Entering directory '/tmp/libtorrent-libtorrent_1_2_0/src'
  CXX      libtorrent_rasterbar_la-session_impl.lo
g++: internal compiler error: Killed (program cc1plus)

Add Libtorrent as system library

You will need to add Libtorrent as a system library or qBittorrent-nox won't run after you compile it.

Create file /etc/ld.so.conf.d/libtorrent.conf with contents

/usr/local/lib

Run sudo ldconfig afterward.

Compiling qBittorrent-nox

Compile 4.1.x version

To get the qBittorrent-nox source code, either

A. compile a cloned git repository or

B. download a release source code.

A. git clone from repository

git clone -b v4_1_x https://github.com/qbittorrent/qBittorrent
cd qBittorrent

You may select the branch version on the branches page.

B. Download the release source code

Using release release-4.1.5 in this example,

wget https://github.com/qbittorrent/qBittorrent/archive/release-4.1.5.zip
unzip release-4.1.5.zip
cd qBittorrent-release-4.1.5

Compile qBittorrent-nox

./configure --disable-gui --enable-systemd --with-boost-libdir=/usr/lib/arm-linux-gnueabihf
make -j$(nproc)
sudo make install

NOTE: Review Ubuntu/Debian compilation guide if you want to run qBittorrent with a GUI.

The binary should be located at /usr/local/bin/qbittorrent-nox. If qbittorrent-nox was installed using apt then that binary will be at /usr/bin/qbittorrent-nox. Do not confuse them!

WebUI access information

qBittorrent-nox is currently installed as a terminal application, which is not optimal for headless use. We now will add qBittorrent-nox as a service.

Running qBittorrent-nox on boot

Add user for qBittorrent-nox service

sudo useradd -rm qbittorrent -G dietpi -s /usr/sbin/nologin

Create systemd service file

UPDATE: this may not be necessary if qBittorrent compilation was configured with flag --enable-systemd.

Create a systemd service file at /etc/systemd/system/qbittorrent.service. Contents are:

Description=qBittorrent Daemon Service
After=network.target

[Service]
User=qbittorrent
Group=dietpi
ExecStart=/usr/local/bin/qbittorrent-nox
ExecStop=/usr/bin/killall -w qbittorrent-nox

[Install]
WantedBy=multi-user.target

Run and check systemd service status

sudo systemctl daemon-reload
sudo systemctl start qbittorrent
sudo systemctl status qbittorrent

The systemctl status command should show qBittorrent-nox is active and running.

Enable qbittorrent service during boot.

sudo systemctl enable qbittorrent

Updating qBittorrent-nox

Get a copy of the latest qBittorrent release version

On DietPi, you will need to run the following commands to update an already compiled version of qBittorrent-nox:

systemctl stop qbittorrent
./configure --disable-gui --with-boost-libdir=/usr/lib/arm-linux-gnueabihf --prefix=/usr/local/bin/
sudo make -j$(nproc)
make install

check version to verify that the binary got updated.

sudo systemctl stop qbittorrent

/usr/local/bin/qbittorrent-nox --version

If the version has changed then the new version was successfully compiled and installed!

Restart the qbittorrent service.

sudo systemctl start qbittorrent
Clone this wiki locally
You can’t perform that action at this time.