These steps has been tested with following configuration:
Target: Raspberry Pi4 (Also backward compatible with Pi3)
Arch: 32 bit
OS: 2022-01-28-raspios-bullseye-armhf
Compiler: gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf
Qt Version: 5.15.3
Graphic Driver: V3D (eglfs_kms)
[on RPi] Install a bunch of development files
sudo nano /etc/apt/sources.list
and ensure that thedeb-src
lines are not commented out
sudo apt update && sudo apt upgrade -y
sudo apt-get build-dep qt4-x11
sudo apt-get build-dep qtbase-opensource-src
sudo apt-get install libegl1-mesa libegl1-mesa-dev libgles2-mesa libgles2-mesa-dev
sudo apt-get install wiringpi libnfc-bin libnfc-dev fonts-texgyre libts-dev
sudo apt-get install libbluetooth-dev bluez-tools gstreamer1.0-plugins* libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libopenal-data libsndio7.0 libopenal1 libopenal-dev pulseaudio
[on RPi] Permit rsync to do sudo operation
echo "$USER ALL=NOPASSWD:$(which rsync)" | sudo tee --append /etc/sudoers
[on RPi] Prepare our target directory
sudo mkdir /usr/local/qt5pi
sudo chown pi:pi /usr/local/qt5pi
[on host] Create our working directory and get a toolchain:
mkdir ~/raspi cd ~/raspi
mkdir -p build qt5pi qt5pi_host
sudo reboot
[on host] Create directories and download tools.
mkdir -p rootfs rootfs/usr rootfs/opt
[on host] Create a sysroot. Using rsync we can properly keep things synchronized in the future as well.
mkdir -p rootfs rootfs/usr rootfs/opt
rsync -avz --rsync-path="sudo rsync" --delete pi@yourpi:/lib rootfs
rsync -avz --rsync-path="sudo rsync" --delete pi@yourpi:/usr/include rootfs/usr
rsync -avz --rsync-path="sudo rsync" --delete pi@yourpi:/usr/lib rootfs/usr
[on host] Adjust symlinks to be relative. Use provided script, because the old fixQualifiedLibraryPaths is not working properly:
wget https://raw.githubusercontent.com/riscv/riscv-poky/master/scripts/sysroot-relativelinks.py
chmod +x sysroot-relativelinks.py
./sysroot-relativelinks.py rootfs
[on host] Get QT (start with qtbase first)
git clone git://code.qt.io/qt/qtbase.git -b 5.12.6
cd qtbase
[on host] Compile, make, make install
./configure -release -opengl es2 -device linux-rasp-pi3-vc4-g++ -device-option CROSS_COMPILE=~/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- -sysroot ~/raspi/sysroot -opensource -confirm-license -make libs -prefix /usr/local/qt5pi -extprefix ~/raspi/qt5pi -hostprefix ~/raspi/qt5 -no-use-gold-linker -v make -j4 make install
cd build
../qt-everywhere-src-5.15.3/configure -release -opengl es2 -device linux-rasp-pi4-v3d-g++ -device-option CROSS_COMPILE=/nishant/qt/rpi/Qt5/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf- -sysroot /nishant/qt/rpi/Qt5/rootfs -opensource -confirm-license -extprefix /nishant/qt/rpi/Qt5/qt5pi4 -prefix /usr/local/qt5pi4 -hostprefix /nishant/qt/rpi/Qt5/qt5pi4_host -make libs -v -nomake examples -nomake tests -no-use-gold-linker
[on host] Deploy Qt to the device. We simply sync everything from ~/raspi/qt5pi to the prefix we configured above.
rsync -avz qt5pi/ pi@yourrpi:/usr/local/qt5pi/
[on RPi] Update the device to let the linker find the Qt libs:
echo /usr/local/qt5pi/lib | sudo tee /etc/ld.so.conf.d/qt5pi.conf
sudo ldconfig