qbittorrent mipsel交叉编译

个人原创,转载请注明出处!!!

前言

本文主要记录了qBittorrent 在Pandorabox(Openwrt)下的交叉编译(基于mipsel架构),编译方式原始,非生成ipk安装包而是直接可运行的二进制执行文件,需要自己手动去链接,已经会初步编译ipk包了。

qBittorrent是一款开源的,轻量级的,基于Qt框架所编写的BT下载工具,wiki页面:https://github.com/qbittorrent/qBittorrent/wiki

这里附上已经编译好的qBittorrent程序文件和自动部署脚本,详情请移步:https://github.com/jsp1256/qBittorrent_cross_complie

在我的Github上,已经为MT7621芯片编译了对应的ipk包,MT7620也可以通过强制安装的方式使用,使用opkg包管理器可以有效的解决依赖问题并能自动的配置和卸载,相当便利,此外也为此添加了Luci配置页面,可以一键式傻瓜安装,装完即可使用。

建议使用3.3.15的稳定版本,目前已知4.4.10版本上传种子文件只能建立一个,已知4.4.13运行一段时间死机(已经排除QT框架以及libtorrent原因),另外,使用libtorrent V1.1.X分支的编译版本会发生段错误。目前正在尝试升级libtorrent 1.0.6=>1.0.11;

推荐使用4.1.3的版本,该版本已经修正GEOIP数据库问题、修正原4.4.10版本的种子批量上传建立的问题。发现开启debug输出可以解决死机问题。手动修改Makefile的编译器CFLAGS、CPPFLAGS的编译参数获得了去掉调试信息(但保留了qDebug调试输出)、启用O3级编译,从而缩减了体积,和原来的release版本大小区别不大。

4.1.3版本发现仍然未解决死机问题,要上V4版本的请换回4.1.0的版本。

目前已经重新编译的4.1.3,修改了编译参数。已经验证了稳定性良好(libtorrent 1.0.x分支)

目前最新编译版本为4.1.5(libtorrent 1.1.x分支)

 

一、环境准备

本机编译环境系统为:UbuntuKylin 18.04.1 LTS 64位。目标机所用系统为pandorabox 17.09,Linux kernel version:3.14.79

SDK:PandoraBox-SDK-ralink-mt7620_gcc-5.5.0_uClibc-1.0.x.Linux-x86_64.tar.xz

编译机安装以下依赖,命令如下:

$ sudo apt-get install gcc pkg-config make build-essential automake autoconf m4 libtool

远端路由器如果需要Qt Creator远端部署则需要安装以下依赖:

opkg update && opkg install openssh-sftp-server

 如果需要用到Qt框架下的gdb调试,编译机还需要安装以下软件包

$ sudo apt-get install python2.7-dev

 二、编译基本依赖

考虑到交叉编译的需要,我又不知道怎么直接把现成的软件包添加到自己的交叉编译工具目录下,于是索性编译各个基本依赖,这样正好也能达到最优适配

首先,统一下按所写代码编译需要声明的前缀:

#统一安装前缀&&环境变量声明:
USER_PREFIX=源主机程序安装前缀
PREFIX=交叉编译程序安装前缀
INCLUDE=$PREFIX/include
LIB=$PREFIX/lib
PKG_CONFIG_PATH=$LIB/pkgconfig:$PREFIX/Qt安装版本/lib/pkgconfig
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH

以下依赖属于基本依赖(软件源中可能有的),需要编译:

zlib

wget http://down.whsir.com/downloads/zlib-1.2.11.tar.gz
tar xvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
CC=mipsel-openwrt-linux-gcc ./configure --prefix=$PREFIX
make && make install

iconv

wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz
tar xf libiconv-1.15.tar.gz
cd libiconv-1.15
./configure --prefix=$PREFIX --host=mipsel-openwrt-linux
make && make install 

boost

这里给出编译boost库的一些过程:
编译boost库,需开启C11支持,否则编译libtorrent无法通过配置(依赖C++11标准,本处也可使用C++17通过)
boost -fPIC参数修复,解决编译libtoorrent链库问题
tools下的gcc.jam文件
修正rule setup-fpic ( targets * : sources * : properties * )下的
if $(link) = shared 为 if $(link) = shared || $(link) = static
生成编译配置
交叉编译修正project-config.jam,
修正using gcc ;为using gcc : mipsel : mipsel-openwrt-linux-gcc ;(空格不可省略)
编译boost库为了解决libtoorrent的依赖(--with-boost-system==mt-sd),仅需编译system库即可
标准安装编译:推荐
./b2 install --layout=tagged --build-type=complete cxxflags="--std=c++17" --with-system
stage编译:
./b2 stage --layout=tagged --build-type=complete cxxflags="-std=c++17" --with-system
最后链接头文件目录boost到编译器的include目录下

openssl:
编译openssl需要根据所使用的libttorrent版本来确定

编译openssl 1.0.2g (libtorrent版本:1.0.x)

编译openssl 1.1.0h (libtorrent版本:1.1.x)

具体的交叉编译过程可看我的另一篇博文:Transmission的交叉编译

 三、QT的移植

 目前最新版本的QT为QT5,但是这里不建议使用,使用QT4.8的源码来构建qmake交叉编译工具链,据我所知,最新的QT5移除了对Mipsel的支持,也许QT5可能存在某些兼容性问题,具体还不得而知,因为使用的是QT4,这里编译的qB的版本不能超过V3.3.x

首先,下载好源码包并解压进入目录

然后修正mkspecs/qws/linux-mips-g++/qmake.conf,替换编译器前缀为交叉编译器前缀(mipsel-openwrt-linux-)
接着执行配置,命令如下:

echo yes | ./configure -prefix $PREFIX -opensource -embedded mips -xplatform qws/linux-mips-g++ -no-webkit -qt-libtiff -qt-libmng -no-mouse-tslib -no-mouse-linuxtp -no-neon -little-endian -host-little-endian -qt-zlib
配置完后按提示编译,安装后会在设定的前缀目录下生成相关文件

 四、编译主要程序和库

开始来编译libtorrent,1.0.6的版本(qb3.3.15要求>=1.0.6)
(注:编译器include目录下需放置openssl的头文件,可以以链接的形式实现或编译器加-I参数)
(注2:该版本openssl必须选用1.0.x的版本,推荐1.0.2g)

sh autotool.sh
./configure --disable-debug --enable-encryption CXXFLAGS="-std=c++11" \
--prefix=$PREFIX --with-libgeoip=yes \
--host=mipsel-openwrt-linux --with-boost-system=mt-sd \
LIBS="-lssl -L$LIB" CXXFLAGS=-I$INCLUDE

 

配置完毕后执行编译安装,完成后能在前缀目录的lib下找到相关库文件

最后编译qb,版本不得高于于3.3.x

先执行配置

./configure --prefix=/home/***/build/install --host=mipsel-openwrt-linux --disable-gui --with-qt4 \
--with-boost-libdir=$PREFIX/lib/ \
--with-boost=$PREFIX \
LIBS="-liconv -L$PREFIX/lib/"

然后这里是需要修改的部分:
base/net/smtp.cpp:533:5 替换std::snprintf为snprintf(GCC 5.5.0已经修复这个问题)
execinfo.h文件缺失,暂用本机文件代替,位置:/usr/include/

注释掉stacktrace.h中print_stacktrace()函数内部所有内容,因为我们所使用的C库是uclibc,没有提供相关的函数来回溯堆栈,不得不阉割掉这一功能,以后出错了也不会有任何有关堆栈的错误信息。新版本的OPENWRT使用musl库可以提供堆栈回溯的支持。但是目前我所使用的Pandorabox只有匹配的uClibc库,唉。
src.pro中DEFINES += BOOST_NO_CXX11_RVALUE_REFERENCES修改为DEFINES += BOOST_CXX11_RVALUE_REFERENCES
同时修改conf.pri,去掉-g来取消调试信息。

五、Luci控制界面

这是一个简单的Luci控制界面,对qb做少量的配置并实时显示运行状态

六、后记(Bonus)

实际上,有了QT的框架支持,我们可以很轻松的获得一个可供我们编译,调试程序运行的IDE:Qt Creator

那么下面我将说明如何配置Qt Creator的相关环境和编译工具链

首先,安装Qt Creator:
从Qt官网下载最新的Linux下可执行的安装文件,如果不需要本机的编译工具,只选中Tools中的Qt Creator即可,稍后配置自己编译的工具链即可。

然后,编译Qt上能用的gdb,SDK提供的gdb不支持python脚本而不被QT接受,

#gdb编译(version: 8.1)
(注:我自带的交叉编译工具链提供的gdb不支持python,而Qt Creator从3.1以后就要求gdb带有python支持)
wget -c http://ftp.gnu.org/gnu/gdb/gdb-8.1.tar.xz
tar xf gdb-8.1.tar.xz && cd gdb-8.1
./configure --prefix=/home/***/install --target=mipsel-openwrt-linux-uclibc --with-python
编译安装完后接着从源码目录/gdb/python/lib/gdb拷贝python相关支持
#gdbserver编译(version: 8.1)
cd gdb/gdbserver
./configure --prefix=/home/***/remote_install --host=mipsel-openwrt-linux-uclibc --target=mipsel-openwrt-linux-uclibc

编译安装完毕后将程序拷贝到远端路由器上面去。

接着配置Qt Creator中的Tools==>options== builts & run
在compilers添加交叉编译器,Debuggers下添加gdb调试器,在Qt Version下添加qmake
最后在Kits下配置交叉编译工具链
在Tools==>options== Devices下配置自己的远端设备。

Qt远程部署:
远程部署需要远端安装openssh-sftp-server提供SFTP服务支持

如果路由器找不到openssh-sftp-server,可通过修改部署操作的第三步,禁用sftp并自己编写scp上传命令
TARGET.path 参数决定了软件安装的位置
INSTALL += TARGET 表示TARGET将被安装
在qb的编译中,修改src/unixconf/conf/conf.pri中的PREFIX等相关参数来改变安装或远程部署目录
如果检测空间不够,修改部署操作的空间检测,将位置修改为外挂存储设备即可,但同时也要保证部署位置与检测位置位于同一存储设备下
个人事实证明,当gdb调试器以及远端gdb服务器正常运转时,qt可跟踪程序运行状况并实时调试,相当便利,对于不得已阉割了堆栈回溯打印功能的qb是相当有效。

一切配置完后就能写个测试文件测试测试把!:)

最后,使用已经编译好的qBittorrent下载PT资源的速度真是相当不错,我也不知道为什么,在我的网络环境下,Transmission总是没有速度,而QT基本能秒上几M的速度。

 参考网上的移植教程,尝试对QT5做下移植,没想到居然成功了,4.1.x解决的控制台中文显示乱码的问题,同时自己手动修改源码,调整了磁盘缓存以及修复了GEOIP数据库下载失败的问题。

实际使用发现大量做种的时候效率不高(40+),速度勉强上2M,还主要是一个种子上传的时候。此时负载已经相当高了。得益于硬件NAT的存在,包转发操作主要由下层交换机做硬件交换完成,正常上网以及响应速度并无影响,但是此时无论是CGI页面还是qb管理页面的相应已经明显感受到迟钝了,连ssh连接也不例外。

 

七、编译原稿

 

#统一安装前缀&&环境变量:
USER=xiang
USER_PREFIX=/home/$USER/install
PREFIX=/home/$USER/build/SDK/staging_dir/toolchain-mipsel_24kec+dsp_gcc-5.5.0_uClibc-1.0.x/usr
INCLUDE=$PREFIX/include
LIB=$PREFIX/lib
PKG_CONFIG_PATH=$LIB/pkgconfig:$PREFIX/qt4.8/lib/pkgconfig:$PREFIX/qt5.8.0/lib/pkgconfig
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH

基本依赖:
编译zlib
wget http://down.whsir.com/downloads/zlib-1.2.11.tar.gz
tar xvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
CC=mipsel-openwrt-linux-gcc ./configure --prefix=$PREFIX
make && make install

编译iconv
wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz
tar xf libiconv-1.15.tar.gz
cd libiconv-1.15
./configure --prefix=$PREFIX --host=mipsel-openwrt-linux
make && make install 


编译libgeio
wget -c -O geoip-api-c-1.6.12.zip https://codeload.github.com/maxmind/geoip-api-c/zip/v1.6.12
unzip geoip-api-c-1.6.12.zip && cd geoip-api-c-1.6.12
去除malloc,realloc检测配置
sed -i  's/AC_FUNC_MALLOC//g' configure.ac
sed -i  's/AC_FUNC_REALLOC//g' configure.ac
aclocal
autoconf
libtoolize --automake
automake --add-missing
automake
./configure --prefix=$PREFIX --host=mipsel-openwrt-linux
make && make install

编译boost库 1.56
编译boost库,需开启C11支持,否则编译libtorrent无法通过配置(依赖C++11标准,本处也可使用C++17通过)
极速编译(动态库):推荐
"mipsel-openwrt-linux-gcc"  -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -fPIC -std=c++11 -DBOOST_ALL_NO_LIB=1 -DBOOST_SYSTEM_DYN_LINK=1 -DNDEBUG  -I"." -c -o "error_code.o" "libs/system/src/error_code.cpp"
#修正libtoorrent链接找不到C++11符号的情况
"mipsel-openwrt-linux-gcc"    -o "libboost_system.so.1.56.0" -Wl,-h -Wl,libboost_system.so.1.56.0 -shared -Wl,--start-group "error_code.o"  -Wl,-Bstatic -Wl,-Bdynamic -lstdc++  -Wl,--end-group
boost-system完整编译:
boost -fPIC参数修复,解决编译libtoorrent链库问题
tools下的gcc.jam文件
修正rule setup-fpic ( targets * : sources * : properties * )下的
if $(link) = shared 为 if $(link) = shared || $(link) = static
sed -i 's/if $(link) = shared/if $(link) = shared || $(link) = static/g' tools/build/src/tools/gcc.jam
生成编译配置
sh bootstrap.sh --prefix=$PREFIX
交叉编译修正project-config.jam,
修正using gcc ;为using gcc : mipsel : mipsel-openwrt-linux-gcc ;(空格不可省略)
编译boost库为了解决libtoorrent的依赖,仅需编译system库即可
标准安装编译:
./b2 install --layout=tagged --build-type=complete link=static cxxflags="-std=c++17" --with-system
stage编译:
./b2 stage --layout=tagged --build-type=complete link=static cxxflags="-std=c++17" --with-system
注意链接头文件目录boost到编译器的include目录下

编译boost库 1.68
标准安装编译:
./b2 install --layout=tagged --build-type=complete link=shared cxxflags="-std=c++17" --with-system --with-random --with-chrono
极速编译(修正链接stdc++库):
"mipsel-openwrt-linux-gcc"   -fPIC -pthread -O3 -finline-functions -Wno-inline -Wall -pedantic -std=c++17 -DBOOST_ALL_NO_LIB=1 -DBOOST_SYSTEM_DYN_LINK=1 -DNDEBUG  -I"." -c -o "error_code.o" "libs/system/src/error_code.cpp"
"mipsel-openwrt-linux-gcc"    -o "libboost_system-mt.so.1.68.0" -Wl,-h -Wl,libboost_system-mt.so.1.68.0 -shared -Wl,--start-group "error_code.o"  -Wl,-Bstatic  -Wl,-Bdynamic -lrt -lstdc++ -Wl,--end-group -fPIC -pthread 
"mipsel-openwrt-linux-gcc"   -fPIC -pthread -O3 -finline-functions -Wno-inline -Wall -pedantic -Wextra -Wno-long-long -std=c++17 -DBOOST_ALL_DYN_LINK=1 -DBOOST_ALL_NO_LIB=1 -DBOOST_SYSTEM_DYN_LINK=1 -DBOOST_SYSTEM_NO_DEPRECATED -DNDEBUG  -I"." -c -o "chrono.o" "libs/chrono/src/chrono.cpp"
"mipsel-openwrt-linux-gcc"   -fPIC -pthread -O3 -finline-functions -Wno-inline -Wall -pedantic -Wextra -Wno-long-long -std=c++17 -DBOOST_ALL_DYN_LINK=1 -DBOOST_ALL_NO_LIB=1 -DBOOST_SYSTEM_DYN_LINK=1 -DBOOST_SYSTEM_NO_DEPRECATED -DNDEBUG  -I"." -c -o "thread_clock.o" "libs/chrono/src/thread_clock.cpp"
"mipsel-openwrt-linux-gcc"   -fPIC -pthread -O3 -finline-functions -Wno-inline -Wall -pedantic -Wextra -Wno-long-long -std=c++17 -DBOOST_ALL_DYN_LINK=1 -DBOOST_ALL_NO_LIB=1 -DBOOST_SYSTEM_DYN_LINK=1 -DBOOST_SYSTEM_NO_DEPRECATED -DNDEBUG  -I"." -c -o "process_cpu_clocks.o" "libs/chrono/src/process_cpu_clocks.cpp"
"mipsel-openwrt-linux-gcc"    -o "libboost_chrono-mt.so.1.68.0" -Wl,-h -Wl,libboost_chrono-mt.so.1.68.0 -shared -Wl,--start-group "chrono.o" "thread_clock.o" "process_cpu_clocks.o" "libboost_system-mt.so.1.68.0"  -Wl,-Bstatic  -Wl,-Bdynamic -lrt -lstdc++ -Wl,--end-group -fPIC -pthread -lrt -lstdc++ -lpthread
"mipsel-openwrt-linux-gcc"   -fPIC -pthread -O3 -finline-functions -Wno-inline -Wall -std=c++17 -DBOOST_ALL_NO_LIB=1 -DBOOST_RANDOM_DYN_LINK -DBOOST_SYSTEM_DYN_LINK=1 -DNDEBUG  -I"." -c -o "random_device.o" "libs/random/src/random_device.cpp"
"mipsel-openwrt-linux-gcc"    -o "libboost_random-mt.so.1.68.0" -Wl,-h -Wl,libboost_random-mt.so.1.68.0 -shared -Wl,--start-group "random_device.o" "libboost_system-mt.so.1.68.0"  -Wl,-Bstatic  -Wl,-Bdynamic -lrt -lstdc++ -Wl,--end-group -fPIC -pthread 
cp libboost* $LIB
ln -s &LIB/libboost_chrono-mt.so.1.68.0 &LIB/libboost_chrono-mt.so
ln -s &LIB/libboost_random-mt.so.1.68.0 &LIB/libboost_random-mt.so
ln -s &LIB/libboost_system-mt.so.1.68.0 &LIB/libboost_system-mt.so

编译openssl:
#编译openssl 1.0.2g (libtorrent版本:1.0.x)
wget https://www.openssl.org/source/openssl-1.0.2g.tar.gz
tar xf openssl-1.0.2g.tar.gz
cd openssl-1.0.2g
./config no-asm shared no-engines no-ec no-ec2m no-ssl3 \
no-hw no-deprecated no-dtls zlib-dynamic no-ssl3-method \
no-comp no-nextprotoneg no-sse2 --prefix=$PREFIX
sed -i 's/-m64//g' Makefile
sed -i 's/PLATFORM=linux-x86_64/PLATFORM=mipsel-openwrt-linux/g' Makefile
sed -i 's/CC= gcc/CC= mipsel-openwrt-linux-gcc/g' Makefile
sed -i 's/MAKEDEPPROG= gcc/MAKEDEPPROG= mipsel-openwrt-linux-gcc/g' Makefile
sed -i 's/ nm/ mipsel-openwrt-linux-nm/g' Makefile
sed -i 's/AR= ar/AR= mipsel-openwrt-linux-ar/g' Makefile
sed -i 's/RANLIB= \/usr\/bin\/ranlib\//RANLIB= mipsel-openwrt-linux-ranlib/g' Makefile
make && make install


编译openssl:
#编译openssl 1.0.2p (libtorrent版本:1.0.x)
wget https://www.openssl.org/source/openssl-1.0.2p.tar.gz
tar xf openssl-1.0.2p.tar.gz
cd openssl-1.0.2p
./config no-asm shared no-engines no-ec no-ec2m no-ssl3 \
no-hw no-deprecated no-dtls zlib-dynamic no-ssl3-method \
no-comp no-nextprotoneg no-sse2 --prefix=$PREFIX
sed -i 's/-m64//g' Makefile
sed -i 's/PLATFORM=linux-x86_64/PLATFORM=mipsel-openwrt-linux/g' Makefile
sed -i 's/CC= gcc/CC= mipsel-openwrt-linux-gcc/g' Makefile
sed -i 's/MAKEDEPPROG= gcc/MAKEDEPPROG= mipsel-openwrt-linux-gcc/g' Makefile
sed -i 's/ nm/ mipsel-openwrt-linux-nm/g' Makefile
sed -i 's/AR= ar/AR= mipsel-openwrt-linux-ar/g' Makefile
sed -i 's/RANLIB= \/usr\/bin\/ranlib\//RANLIB= mipsel-openwrt-linux-ranlib/g' Makefile
make && make install


#编译openssl 1.1.0h (libtorrent版本:1.1.x)
cd $BUILD_ROOT
wget https://www.openssl.org/source/openssl-1.1.0h.tar.gz
tar zxf openssl-1.1.0h.tar.gz
cd openssl-1.1.0h
./config no-asm --prefix=$PREFIX
sed -i  's/-m64//g' Makefile
sed -i  's/CROSS_COMPILE= /CROSS_COMPILE=mipsel-openwrt-linux-/g' Makefile
make && make install

QT:
QT4移植Mipsel,qt版本:4.8.0
修正mkspecs/qws/linux-mips-g++/qmake.conf,替换编译器前缀为交叉编译器前缀(mipsel-openwrt-linux-)
echo yes | ./configure -prefix $PREFIX/qt4.8 -opensource -embedded mips -xplatform qws/linux-mips-g++ -no-webkit -qt-libtiff -qt-libmng -no-mouse-tslib -no-mouse-linuxtp -no-neon -little-endian -host-little-endian -qt-zlib
按提示编译,安装后会在设定的前缀目录下生成相关文件

QT5移植Mipsel,qt版本:5.5.1
./configure -v -prefix $PREFIX/qt5.5.1 -xplatform qws/linux-mips-g++ -confirm-license -opensource -nomake tests -nomake examples \
-qt-sql-sqlite \
-no-openvg \
-no-eglfs

QT5移植Mipsel,qt版本:5.8.0
./configure -v -prefix $PREFIX/qt5.8.0 -xplatform qws/linux-mips-g++ -confirm-license -opensource -nomake tests -nomake examples \
-no-eglfs -no-opengl -I$INCLUDE -L$LIB
make && make install

以下为可选操作:
#安装Qt Creator:
从Qt官网下载最新的Linux下可执行的安装文件,如果不需要本机的编译工具,只选中Tools中的Qt Creator即可,稍后配置自己编译的工具链即可。

#gdb编译(version: 8.1)
前提要求:
sudo apt-get install python2.7-dev
(注:我自带的交叉编译工具链提供的gdb不支持python,而Qt Creator从3.1以后就要求gdb带有python支持)
wget -c http://ftp.gnu.org/gnu/gdb/gdb-8.1.tar.xz
tar xf gdb-8.1.tar.xz && cd gdb-8.1
./configure --prefix=/home/xiang/install --target=mipsel-openwrt-linux-uclibc --with-python
make && make install
需要从源码目录/gdb/python/lib/gdb拷贝python相关支持
cp -r gdb/python/lib/gdb/ /home/xiang/install/share/gdb/python/

#gdbserver编译(version: 8.1)
cd gdb/gdbserver
./configure --prefix=/home/xiang/remote_install --host=mipsel-openwrt-linux-uclibc --target=mipsel-openwrt-linux-uclibc
make && make install

配置Qt Creator中的Tools==>options== builts & run
在compilers添加交叉编译器,Debuggers下添加gdb调试器,在Qt Version下添加qmake
最后在Kits下配置交叉编译工具链
#可选配置:在Tools==>options== Devices下配置自己的远端设备。

#Qt远程部署:
远程部署需要远端安装openssh-sftp-server提供SFTP服务支持
如果远端不支持sftp部署,将部署的第三步换成SCP上传,自己写命令。
TARGET.path 参数决定了软件安装的位置
INSTALL += TARGET 表示TARGET将被安装
在qb的编译中,修改src/unixconf/conf/conf.pri中的PREFIX等相关参数来改变安装或远程部署目录
如果检测空间不够,修改部署操作的空间检测,将位置修改为外挂存储设备即可,但同时也要保证部署位置与检测位置位于同一存储设备下
个人事实证明,当gdb调试器以及远端gdb服务器正常运转时,qt可跟踪程序运行状况并实时调试,相当便利,对于不得已阉割了堆栈回溯打印功能的qb是相当有效。

#Qt安装配置:
在bin目录(与qmake同一目录)里新建一个文件qt.conf,文件内容如下:
[Paths]
Prefix=$QT_INSTALL_PATH

主要程序和库:
libtorrent编译配置,1.0.x的版本(qb3.3.15要求>=1.0.6)
(注:编译器include目录下需放置openssl的头文件,可以以链接的形式实现或编译器加-I参数)
(注2:该版本openssl必须选用1.0.x的版本,推荐1.0.2g)
#编译版本:1.0.6
wget https://github.com/arvidn/libtorrent/archive/libtorrent-1_0_6.tar.gz
tar xf libtorrent-1_0_6.tar.gz
cd libtorrent-1_0_6
sh autotool.sh
./configure --disable-debug --enable-encryption --prefix=$PREFIX \
--with-libiconv \
--host=mipsel-openwrt-linux --with-boost-system=boost_system \
LIBS="-L$LIB" CXXFLAGS="-std=c++11 -I$INCLUDE"
make && make install
#编译版本:1.0.11
wget https://github.com/arvidn/libtorrent/archive/libtorrent-1_0_11.tar.gz
tar xf libtorrent-1_0_11.tar.gz
cd libtorrent-1_0_11
sh autotool.sh
./configure --disable-debug --enable-encryption --prefix=$PREFIX \
--with-libiconv --with-boost=$PREFIX --with-openssl=$PREFIX \
--host=mipsel-openwrt-linux --with-boost-system=boost_system \
LIBS="-L$LIB" CXXFLAGS="-std=c++11 -I$INCLUDE"
make && make install
开启statistics、disk-stats需要在session_impl.cpp额外添加定义
#ifdef TORRENT_LINUX
#define RUSAGE_THREAD 1
#endif

libtorrent编译配置,建议使用1.0.x的版本(qb3.3.15要求>=1.0.6)
(注:该编译配置对应1.1.x版本)
sh autotool.sh
./configure --disable-debug --enable-encryption --prefix=$PREFIX \
--with-libiconv --host=mipsel-openwrt-linux \
LIBS="-L$LIB" CXXFLAGS="-std=c++11 -I$INCLUDE" --with-boost=$PREFIX 
make && make install


qb编译配置,版本不得高于于3.3.x
./configure --prefix=$PREFIX --host=mipsel-openwrt-linux --disable-gui \
--with-qt4 --with-boost=$PREFIX \
LIBS="-L$LIB" CXXFLAGS="-std=c++11 -I$INCLUDE"
需要修改的部分:
base/net/smtp.cpp:533:5 替换std::snprintf为snprintf
execinfo.h文件缺失,暂用本机文件代替,位置:/usr/include/
src.pro中DEFINES += BOOST_NO_CXX11_RVALUE_REFERENCES修改为DEFINES += BOOST_CXX11_RVALUE_REFERENCES
由于嵌入式设备使用uclibc而不是glibc,无backtrace以及backtrace_symbols的函数,需要阉割堆栈跟踪
也可在经过configure配置后进入src目录启动Qt Creator

qb编译配置,版本v4.1.x
./configure --prefix=$PREFIX --host=mipsel-openwrt-linux --disable-gui \
--with-boost=$PREFIX \
LIBS="-L$LIB" CXXFLAGS="-std=c++11 -I$INCLUDE"

qb编译配置,版本v4.1.3
wget https://github.com/qbittorrent/qBittorrent/archive/release-4.1.3.tar.gz
tar xf release-4.1.3.tar.gz
cd qBittorrent-release-4.1.3
./configure --prefix=$PREFIX --host=mipsel-openwrt-linux \
--disable-gui --with-boost=$PREFIX \
LIBS="-L$LIB" CXXFLAGS="-I$INCLUDE"
make && make install 

目前已探知的编译方式如下(仅列出变动项目):
qBittorent 3.3.15 + libttorent 1.0.6 + openssl 1.0.2g(本机平台测试通过,嵌入式IPV4测试通过)
qBittorent 3.3.16 + libttorent 1.1.9 + openssl 1.1.0h(嵌入式设备工作不正常)
qBittorent 4.1.0 + libttorent 1.0.6 + openssl 1.0.2g(测试通过,Qt Creator执行编译)

目前已知4.1.3、4.0.4、4.1.1的release编译版本运行一段时间后CPU 100%负载,卡在循环等待中。
已经排除Boost库、Qt框架、libtorrent原因。
另外,卡住的版本多文件添加均正常。
通过启用debug调试输出、去掉-g参数来保证生成的大小,暂时解决了这个问题。

 

posted @ 2018-08-22 15:52  jsp1256  阅读(3380)  评论(8编辑  收藏  举报