Loading... ## 1. 前言 官方已经停止维护 qBittorent4.1.9,ubuntu ppa 上也没有此版本。但是由于一些PT站点只允许4.1.9的客户端连接,只能选择编译安装,编译过程中还遇到了一些问题,特此记录一下。 版本号中的 `-nox` 代表的是服务器端没有GUI界面,后续可以通过网页来操作。 官方qBittorent的编译教程链接如下: [Compilation Debian and Ubuntu · qbittorrent/qBittorrent Wiki](https://github.com/qbittorrent/qBittorrent/wiki/Compilation-Debian-and-Ubuntu) 编译时操作系统: - 操作系统:Ubuntu 22.04 - 内核:6.8.0-51-generic - 架构:x86\_64 ## 2. 安装依赖 boost和其他一些依赖: ```bash sudo apt install build-essential pkg-config automake libtool git zlib1g-dev libssl-dev libgeoip-dev sudo apt install libboost-dev libboost-system-dev libboost-chrono-dev libboost-random-dev ``` 运行时依赖: ```bash sudo apt install python3 ``` Qt框架: ```bash sudo apt install qtbase5-dev qtbase5-private-dev qttools5-dev libqt5svg5-dev ``` ## 3. 编译安装 libtorrent #### 克隆 libtorrent 仓库 ```bash git clone https://github.com/arvidn/libtorrent.git cd libtorrent ``` #### 选择合适的 libtorrent 版本 根据所需的 libtorrent 版本,选择适当的 git 和编译命令。以下是支持的版本系列和编译命令: | libtorrent 版本系列 | qBittorrent 支持版本 | git 命令(示例) | 编译命令 | |---------------------|----------------------|-----------------|---------------------| | 1.2.x | >= 4.2.0 | `git checkout libtorrent-1_2_5` | 使用 CMake:`cmake -B cmake-build-dir/release -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=14` `cmake --build cmake-build-dir/release` 使用 autotools:`./autotool.sh` `./configure --disable-debug --enable-encryption CXXFLAGS="-std=c++14"` `make clean && make -j$(nproc)` | | 1.1.x | >= 3.3.8 且 < 4.2.0 | `git checkout libtorrent-1_1_14` | 使用 CMake:`cmake -B cmake-build-dir/release -DCMAKE_BUILD_TYPE=Release` `cmake --build cmake-build-dir/release` 使用 autotools:`./autotool.sh` `./configure --disable-debug --enable-encryption` `make clean && make -j$(nproc)` | | 1.0.x | <= 4.1.5 | `git checkout libtorrent-1_0_11` | 同1.1.x | #### 编译安装 libtorrent 如果使用 CMake 编译: ```bash sudo cmake --install cmake-build-dir/release ``` 如果使用 autotools 编译: ```bash sudo make install ``` ## 4. 安装 qBittorent #### 下载源代码 从 GitHub 克隆 git 仓库: ```bash git clone https://github.com/qbittorrent/qBittorrent ``` 使用 `master` 分支,选择 4.1.9.1 版本。 ```bash git checkout release-4.1.9.1 ``` #### 配置 在终端窗口中打开文件夹并运行以下命令来配置: ```bash ./configure CXXFLAGS="-std=c++14" --disable-gui ``` #### 编译 qBittorrent 配置成功后,运行以下命令进行编译: ```bash make -j$(nproc) ``` <div class="tip inlineBlock info"><code>$(nproc)</code>:CPU 核心数。<code>make -j</code> 后的数字越大,编译的速度就越快,这里使用全部cpu核心用于编译。</div> #### 安装 qBittorrent ``` sudo make install ``` ## 5. qBittorrent 编译安装时遇到的问题 ### 在编译 `piecesbar.cpp` 时报错 ```cpp compiling gui/properties/piecesbar.cpp gui/properties/piecesbar.cpp: In member function ‘virtual void PiecesBar::paintEvent(QPaintEvent*)’: gui/properties/piecesbar.cpp:198:18: error: aggregate ‘QPainterPath border’ has incomplete type and cannot be defined 198 | QPainterPath border; | ^~~~~~ make[1]: *** [Makefile:3408:piecesbar.o] 错误 1 ``` 代码未包含 `#include <QPainterPath>` 头文件。也有可能是Qt 版本不兼容,导致 `QPainterPath` 解析失败。 找到 `piecesbar.cpp` 添加 `#include <QPainterPath>`。 确保 `qtbase5-dev` 已经安装: ```bash sudo apt install qtbase5-dev ``` ### 编译 `qBittorrent` 时报错 ```cpp compiling moc_webui.cpp linking qbittorrent /usr/bin/ld: 找不到 -lvals-NOTFOUND: 没有那个文件或目录 collect2: error: ld returned 1 exit status make[1]: *** [Makefile:1038:qbittorrent] 错误 1 make[1]: 离开目录“/home/nailoy/Softwares/qbittorrent-4.1.9.1/src” make: *** [Makefile:47:sub-src-make_first] 错误 2 ``` 由 `pkg-config` 文件或 `LDFLAGS` 配置问题引起的错误,引用了一个未找到的库,可能是 `cmake` 或 `pkg-config` 生成的错误路径。 检查环境变量 `LDFLAGS`,确保没有将一个无效的库路径添加到 `LDFLAGS` 环境变量中。 ```bash echo $LDFLAGS ``` <br> 同时检查是否存在不正确的 pkg-config 文件: ```bash find /usr/local /usr/share -name "\*.pc" | xargs grep "vals" ``` 返回以下结果,确认错误是由 `pkgconfig` 引起的: ```bash /usr/local/lib/pkgconfig/libtorrent-rasterbar.pc:Libs: -L${libdir} -ltorrent-rasterbar -L/usr/lib/x86_64-linux-gnu -lssl -lcrypto -lvals-NOTFOUND -lboost_system ``` 找到这个文件并删除其中的 `-lvals-NOTFOUND` ### 重新编译安装 清理 `config.log` 和 `config.status` 文件: ```bash rm config.log config.status ``` 清理编译文件: ```bash make clean ``` 重新编译: ```bash make -j$(nproc) sudo make install ``` ## 6. 运行 如果安装成功可以在控制台输入以下命令来运行: ```bash qbittorrent-nox ``` 浏览器访问 `http://localhost:7777/` Web UI 的初始用户名为 `admin` ,初始密码为 `adminadmin` 最后修改:2025 年 02 月 13 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 2 你的支持是我最大的动力