静看光阴荏苒
不管不顾不问不说也不念

openSUSE Leap15.3编译qBittorrent-nox4.3.9

现在编译libtorrent和qbittorrent官方都推荐用cmake和ninja了,用这样一套工具来编译的话确实比之前方便了不少,而且编译速度也大幅度提升。这里记录一下在opensuse上的编译过程。

安装编译所需的依赖包:

sudo zypper in -t pattern -y devel_basis
sudo zypper in -t pattern -y devel_C_C++
sudo zypper in -t pattern -y devel_qt5
sudo zypper in -y cmake-full ninja libopenssl-devel \
libboost_system1_66_0-devel libboost_chrono1_66_0-devel libboost_random1_66_0-devel

先编译libtorrent,拉取项目文件:

cd ~
git clone https://github.com/arvidn/libtorrent.git
cd libtorrent

这里选择编译1.2.15版本:

git checkout v1.2.15

生成编译用的文件,这里一定要指定c++版本为14:

cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=14

编译,后面的8是指编译用的cpu核心数量,根据自己的需要修改即可:

cmake --build build --parallel 8

等待编译完成后即可安装libtorrent:

sudo cmake --install build

使用cmake编译的一个好处是可以跟踪到安装的文件,在build目录内会有一个install_manifest.txt,这个文件内记录了安装的所有文件。

后续要卸载安装的文件就很容易了:

cd build
sudo xargs rm < install_manifest.txt

现在编译qbittorrent,拉取项目文件:

cd ~
git clone https://github.com/qbittorrent/qBittorrent
cd qBittorrent/

这里选择编译4.3.9版本:

git checkout release-4.3.9

我只需要nox版本,所以配置选项加上GUI=OFF:

cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DGUI=OFF

所有可用的配置选项可在这里查看:https://github.com/qbittorrent/qBittorrent/wiki/Compilation-with-CMake:-common-information

编译:

cmake --build build --parallel 8

编译完成后即可安装qbittorrent:

sudo cmake --install build

如果要卸载编译安装的qbittorrent:

cd build
sudo xargs rm < install_manifest.txt

新建systemd服务文件:

nano /etc/systemd/system/qbittorrent.service

写入如下配置,注意修改user:

[Unit]
Description=qBittorrent-nox service
Documentation=man:qbittorrent-nox(1)
Wants=network-online.target
After=network-online.target nss-lookup.target

[Service]
Type=exec
User=imlala
ExecStart=/usr/local/bin/qbittorrent-nox
AmbientCapabilities=CAP_NET_RAW

[Install]
WantedBy=multi-user.target

启动并设置开机自启:

systemctl enable --now qbittorrent

这里记录一点额外的内容。在github上面有一个项目提供静态编译qb-nox的脚本:

https://github.com/userdocs/qbittorrent-nox-static

这个脚本在suse上是不能用的,但是作者会发布预编译好的二进制文件,如果你需要这种完全静态编译的版本,直接去上面的存储库下载就能用了。

赞(6)
未经允许不得转载:荒岛 » openSUSE Leap15.3编译qBittorrent-nox4.3.9
分享到: 更多 (0)

评论 2

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #1

    为什么不用libtorrent-2.0.5

    z2年前 (2022-02-22) Firefox 97.0 Firefox 97.0 Windows 10 x64 Edition Windows 10 x64 Edition回复

分享创造快乐

广告合作资源投稿