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/xjp/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/xjp/install --target=mipsel-openwrt-linux-uclibc --with-python
編譯安裝完后接着從源碼目錄/gdb/python/lib/gdb拷貝python相關支持
#gdbserver編譯(version: 8.1)
cd gdb/gdbserver
./configure --prefix=/home/xjp/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參數來保證生成的大小,暫時解決了這個問題。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM