目标机
sudo apt install build-essential cmake unzip pkg-config gfortran
sudo apt build-dep qt5-qmake libqt5gui5 libqt5webengine-data libqt5webkit5 libudev-dev libinput-dev libts-dev libxcb-xinerama0-dev libxcb-xinerama0 gdbserver
sudo apt install libxcb-randr0-dev libxcb-xtest0-dev libxcb-shape0-dev libxcb-xkb-dev
# additional (multimedia) packages
sudo apt install libjpeg-dev libpng-dev libtiff-dev
sudo apt install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt install libxvidcore-dev libx264-dev openjdk-8-jre-headless
# audio packages
sudo apt install libopenal-data libsndio7.0 libopenal1 libopenal-dev pulseaudio
# bluetooth packages
sudo apt install bluez-tools
sudo apt install libbluetooth-dev
# gstreamer (multimedia) packages
sudo apt install libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio
sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
wget https://raw.githubusercontent.com/abhiTronix/raspberry-pi-cross-compilers/master/utils/SSymlinker
sudo chmod +x SSymlinker
./SSymlinker -s /usr/include/aarch64-linux-gnu/asm -d /usr/include
./SSymlinker -s /usr/include/aarch64-linux-gnu/gnu -d /usr/include
./SSymlinker -s /usr/include/aarch64-linux-gnu/bits -d /usr/include
./SSymlinker -s /usr/include/aarch64-linux-gnu/sys -d /usr/include
./SSymlinker -s /usr/include/aarch64-linux-gnu/openssl -d /usr/include
./SSymlinker -s /usr/lib/aarch64-linux-gnu/crtn.o -d /usr/lib/crtn.o
./SSymlinker -s /usr/lib/aarch64-linux-gnu/crt1.o -d /usr/lib/crt1.o
./SSymlinker -s /usr/lib/aarch64-linux-gnu/crti.o -d /usr/lib/crti.o
编译机
sudo apt update
sudo apt dist-upgrade
sudo apt install build-essential cmake unzip gfortran
sudo apt install gcc git bison python gperf pkg-config gdb-multiarch wget
sudo apt-get -y install gcc g++ gperf flex texinfo gawk bison openssl pigz libncurses-dev autoconf automake tar figlet
进入~/目录
sudo mkdir ~/rk-qt
sudo mkdir ~/rk-qt/build
sudo mkdir ~/rk-qt/tools
sudo mkdir ~/rk-qt/sysroot
sudo mkdir ~/rk-qt/sysroot/usr
sudo mkdir ~/rk-qt/sysroot/opt
sudo chown -R yrk:yrk ~/rk-qt
cd ~/rk-qt
编译链
export PATH=$PATH:/home/yrk/lgz/gcc-arm-10.2-2020.11-x86_64-aarch64-none-linux-gnu/bin
QT源文件目录
/home/yrk/tool/qt-everywhere-src-5.15.2
修改
/home/yrk/tool/qt-everywhere-src-5.15.2/qtbase/mkspecs/linux-aarch64-gnu-g++/qmake.conf
QMAKE_CC = aarch64-none-linux-gnu-gcc //注意这里的名字与交叉编译工具bin目录下的名字一致
QMAKE_CXX = aarch64-none-linux-gnu-g++ //注意这里的名字与交叉编译工具bin目录下的名字一致
QMAKE_LINK = aarch64-none-linux-gnu-g++ //注意这里的名字与交叉编译工具bin目录下的名字一致
QMAKE_LINK_SHLIB = aarch64-none-linux-gnu-g++ //注意这里的名字与交叉编译工具bin目录下的名字一致
# modifications to linux.conf
QMAKE_AR = aarch64-none-linux-gnu-ar cqs //注意这里的名字与交叉编译工具bin目录下的名字一致
QMAKE_OBJCOPY = aarch64-none-linux-gnu-objcopy //注意这里的名字与交叉编译工具bin目录下的名字一致
QMAKE_NM = aarch64-none-linux-gnu-nm -P //注意这里的名字与交叉编译工具bin目录下的名字一致
QMAKE_STRIP =aarch64-none-linux-gnu-strip //注意这里的名字与交叉编译工具bin目录下的名字一致
cd ~/rk-qt
rsync -avz --rsync-path="sudo rsync" --delete linaro@172.16.9.250:/lib sysroot
rsync -avz --rsync-path="sudo rsync" --delete linaro@172.16.9.250:/usr/include sysroot/usr
rsync -avz --rsync-path="sudo rsync" --delete linaro@172.16.9.250:/usr/lib sysroot/usr
rsync -avz --rsync-path="sudo rsync" --delete linaro@172.16.9.250:/opt/vc sysroot/opt
注意:rsync命令研究一下,只要从目标机下载到本机即可
将交叉编译依赖的文件下载到本地后执行下面命令,恢复链接
wget https://raw.githubusercontent.com/riscv/riscv-poky/master/scripts/sysroot-relativelinks.py
sudo chmod +x sysroot-relativelinks.py
./sysroot-relativelinks.py sysroot
configure找不到nss
export PKG_CONFIG_PATH=/home/yrk/rk-qt/sysroot/usr/lib/pkgconfig:/home/yrk/rk-qt/sysroot/usr/share/pkgconfig:/home/yrk/rk-qt/sysroot/usr/lib/aarch64-linux-gnu/pkgconfig
#!/bin/sh
./configure -release -qt-libjpeg -qt-libpng -qt-zlib -qt-pcre -xplatform linux-aarch64-gnu-g++ -sysroot ~/rk-qt/sysroot -prefix /home/yrk/tool/aarch64-qt-output -opensource -confirm-license -skip qtscript -skip qtwayland -nomake tests -skip qtlocation -skip qt3d -no-opengl -skip qtcanvas3d -skip qtpurchasing -make libs -pkg-config -v -recheck -L$HOME/rk-qt/sysroot/usr/lib/aarch64-linux-gnu -I$HOME/rk-qt/sysroot/usr/include/aarch64-linux-gnu
编译qtwebengine 遇到问题
1.找不到链接库的原因是虽然添加了sysroot 库在/usr/lib/aarch64-linux-gnu下能找到,但是编译过程却无法找到(下列不全 可能还包含-lrt -ldl -licui18n -licuuc -licudata -ludev)
{
在/home/yrk/tool/qt-everywhere-src-5.15.2/qtbase/mkspecs/linux-aarch64-gnu-g++/qmake.conf 增加
QMAKE_LIBDIR = /home/yrk/rk-qt/sysroot/usr/lib/aarch64-linux-gnu
QMAKE_LIBS = -lrt -ldl -licui18n -licuuc -licudata -ludev -lpthread
}
ln -s aarch64-linux-gnu/libnss3.so libnss3.so
ln -s aarch64-linux-gnu/libnssutil3.so libnssutil3.so
ln -s aarch64-linux-gnu/libsmime3.so libsmime3.so
ln -s aarch64-linux-gnu/libplc4.so libplc4.so
ln -s aarch64-linux-gnu/libnspr4.so libnspr4.so
ln -s aarch64-linux-gnu/libevent-2.1.so.7 libevent-2.1.so.7
ln -s aarch64-linux-gnu/libresolv.so.2 libresolv.so.2
ln -s aarch64-linux-gnu/libexpat.so.1 libexpat.so.1
ln -s aarch64-linux-gnu/libfontconfig.so.1 libfontconfig.so.1
ln -s aarch64-linux-gnu/libxkbcommon.so.0 libxkbcommon.so.0
ln -s aarch64-linux-gnu/libpci.so.3 libpci.so.3
ln -s aarch64-linux-gnu/libz.so.1 libz.so.1
ln -s aarch64-linux-gnu/libdbus-1.so.3 libdbus-1.so.3
ln -s aarch64-linux-gnu/libplds4.so libplds4.so
ln -s aarch64-linux-gnu/libfreetype.so.6 libfreetype.so.6
ln -s aarch64-linux-gnu/libuuid.so.1 libuuid.so.1
ln -s aarch64-linux-gnu/libsystemd.so.0 libsystemd.so.0
ln -s aarch64-linux-gnu/libpng16.so.16 libpng16.so.16
ln -s aarch64-linux-gnu/libbrotlidec.so.1 libbrotlidec.so.1
ln -s aarch64-linux-gnu/liblzma.so.5 liblzma.so.5
ln -s aarch64-linux-gnu/libzstd.so.1 libzstd.so.1
ln -s aarch64-linux-gnu/liblz4.so.1 liblz4.so.1
ln -s aarch64-linux-gnu/libgcrypt.so.20 libgcrypt.so.20
ln -s aarch64-linux-gnu/libbrotlicommon.so.1 libbrotlicommon.so.1
ln -s aarch64-linux-gnu/libgpg-error.so.0 libgpg-error.so.0
2.错误信息:jidctfst-neon.c:88:29: 错误: 用'int64x1_t'初始化'int_64' {或称‘long int’}时类型不兼容 每个地方都需要
int64_t left_ac_bitmap = vreinterpret_s64_s16(bitmap))
修改方法:此处是代码问题,需要修改代码,=号量表类型不一致,问题代码为:
int64_t left_ac_bitmap = vreinterpret_s64_s16(vget_low_s16(bitmap));
修改为
int64_t left_ac_bitmap = vget_lane_s64(vreinterpret_s64_s16(vget_low_s16(bitmap)),0);
3.错误信息:错误: 'vaddq_s8'的第2个实参类型不兼容
修改方法:代码问题,需要修改代码,实参类型与虚参类型不一致,问题代码为:
vaddq_s8(cols_01_s8, vdupq_n_u8(CENTERJSAMPLE)));
修改为
vaddq_s8(cols_01_s8, vreinterpretq_s8_u8(vdupq_n_u8(CENTERJSAMPLE))));
4./usr/bin/g++ 找不到so的 直接apt安装
5.third_party/ffmpeg/ffmpeg_internal/videodsp.o: in function `ff_prefetch_aarch64':
(.text+0x10): relocation truncated to fit: R_AARCH64_CONDBR19 against symbol `ff_prefetch_aarch64' defined in .text section in obj/third_party/ffmpeg/ffmpeg_internal/videodsp.o
third_party/ffmpeg/libavcodec/aarch64/videodsp.S
#include "libavutil/aarch64/asm.S"
function ff_prefetch_aarch64, export=1
subs w2, w2, #2
prfm pldl1strm, [x0]
prfm pldl1strm, [x0, x1]
add x0, x0, x1, lsl #1
b.gt X(ff_prefetch_aarch64)
ret
endfunc
原因:由于链接器如何将部分分配到地址空间造成的
修改以下文件
third_party/ffmpeg/libavcodec/aarch64/videodsp.S:
#include "libavutil/aarch64/asm.S"
function ff_prefetch_aarch64, export=1
subs w2, w2, #2
prfm pldl1strm, [x0]
prfm pldl1strm, [x0, x1]
add x0, x0, x1, lsl #1
b X(ff_prefetch_aarch64)
1:
ret
endfunc
移动安装文件位置的一些处理
这里主要会有2个问题
1、QMAKESPEC环境变量的问题,找不到mkspecs
直接导出QMAKESPEC环境变量
或者
使用qmake的参数 -spec 指定mkspece位置如:
../qt4.8.5/bin/qmake zytk_YT312.pro -spec ../qt4.8.5/mkspecs/linux-arm-gnueabi-g++
2、qmake找qt安装的库的位置问题
需要在qmake同一文件夹下,创建一个qt.conf文件内容为
[Paths]
Prefix=../
Libraries=lib
Plugins=plugins
HostLibraries=lib