Skip to content

Instantly share code, notes, and snippets.

@notsure2
Last active November 13, 2022 21:06
Show Gist options
  • Save notsure2/f8eac873eb7298d89d551047779d8361 to your computer and use it in GitHub Desktop.
Save notsure2/f8eac873eb7298d89d551047779d8361 to your computer and use it in GitHub Desktop.
How to compile latest qBittorrent-nox with static qt and boost for Debian Stretch 9.0 (using Debian Stretch 9.0)
#!/bin/sh
set -e
apt install -y build-essential git perl python2.7 libboost-all-dev libboost-tools-dev zlib1g-dev autoconf libssl-dev
QBITTORRENT_TAG=v4_2_x
LIBTORRENT_TAG=RC_1_2
QT5_TAG=5.12
rm -rf work
mkdir work
cd work
git clone https://github.com/qt/qtbase.git --branch $QT5_TAG --single-branch --depth 1
cd qtbase
./configure -static -openssl-linked -opensource \
-confirm-license -c++std 14 -no-opengl -no-dbus -no-widgets -no-gui -no-compile-examples \
-prefix `pwd`/../qt-qbittorrent
make -j$(nproc)
make install
cd ..
PATH="`pwd`/qt-qbittorrent/bin:$PATH"
git clone https://github.com/qt/qttools.git --branch $QT5_TAG --single-branch --depth 1
cd qttools
qmake
make -j$(nproc)
make install
cd ..
git clone https://github.com/arvidn/libtorrent.git --branch $LIBTORRENT_TAG --single-branch --depth 1
cd libtorrent
b2 link=static variant=release boost-link=static dht=on encryption=on crypto=openssl i2p=on extensions=on
cd ..
git clone https://github.com/qbittorrent/qBittorrent.git --branch $QBITTORRENT_TAG --single-branch --depth 1
cd qBittorrent
QT_QMAKE=`pwd`/../qt-qbittorrent/bin \
LDFLAGS="-l:libboost_system.a" \
CXXFLAGS="-std=c++14" \
libtorrent_CFLAGS="-I`pwd`/../libtorrent/include" \
libtorrent_LIBS="-L`pwd`/../libtorrent/bin/gcc-6.3.0/release/boost-link-static/crypto-openssl/link-static/threading-multi -l:libtorrent.a" \
./configure --disable-gui --disable-qt-dbus
sed -i 's/-lboost_system//' conf.pri
make -j$(nproc)
cd ../..
cp ./work/qBittorrent/src/qbittorrent-nox .
@kerastinell
Copy link

kerastinell commented Feb 7, 2020

There are several improvements that could be made for this script:

  1. The apt install line lacks pkg-config, without it the qBittorrent build command (line 38) will crash on Debian 9.0.1 Live
  2. b2 command could be sped up by adding -j$(nproc) to the end of it
  3. The size of resulting qbittorrent-nox could be greatly reduced (from 59 to 16 MB) by running strip after building the binary. For example, running strip ./qbittorrent-nox -o ./qbittorrent-nox-stripped will create a stripped binary and keep the old one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment