https://fecub.wordpress.com/2018/01/15/compile-qt-for-raspberry-pi/
http://www.tal.org/tutorials/building-qt-510-raspberry-pi-debian-stretch
$ apt-get install build-essential libfontconfig1-dev libdbus-1-dev libfreetype6-dev libicu-dev libinput-dev libxkbcommon-dev libsqlite3-dev libssl-dev libpng-dev libjpeg-dev libglib2.0-dev libraspberrypi-dev libudev-dev libts-dev libxcb-xinerama0-dev libxcb-xinerama0
$ apt-get install bluez libbluetooth-dev
$ apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly gstreamer1.0-plugins-bad libgstreamer-plugins-bad1.0-dev gstreamer1.0-pulseaudio gstreamer1.0-tools gstreamer1.0-alsa
$ apt-get install libasound2-dev
$ apt-get install pulseaudio libpulse-dev
$ apt-get install libpq-dev libmariadbclient-dev
$ apt-get install libcups2-dev
$ apt-get install libwayland-dev
$ apt-get install libx11-dev libxcb1-dev libxkbcommon-x11-dev libx11-xcb-dev libxext-dev
$ apt-get install libatspi-dev
to build specific module see the Qt doc to know dependencies to install
$ sudo mv /usr/lib/arm-linux-gnueabihf/libEGL.so.1.0.0 /usr/lib/arm-linux-gnueabihf/libEGL.so.1.0.0_backup
$ sudo mv /usr/lib/arm-linux-gnueabihf/libGLESv2.so.2.0.0 /usr/lib/arm-linux-gnueabihf/libGLESv2.so.2.0.0_backup
$ sudo ln -s /opt/vc/lib/libEGL.so /usr/lib/arm-linux-gnueabihf/libEGL.so.1.0.0
$ sudo ln -s /opt/vc/lib/libGLESv2.so /usr/lib/arm-linux-gnueabihf/libGLESv2.so.2.0.0
$ sudo ln -s /opt/vc/lib/libEGL.so /opt/vc/lib/libEGL.so.1
$ sudo ln -s /opt/vc/lib/libGLESv2.so /opt/vc/lib/libGLESv2.so.2
$ cd
$ mkdir ~/rpi
$ cd rpi
$ mkdir sysroot sysroot/usr sysroot/opt qt-build qt-build-local
Paste the following bash script into a named file rsync.sh (change port, ip address and remote user accordingly to your configuration)
#!/bin/bash
rsync -avz -e "ssh -p 13377" [email protected]:/lib sysroot
rsync -avz -e "ssh -p 13377" [email protected]:/usr/include sysroot/usr
rsync -avz -e "ssh -p 13377" [email protected]:/usr/lib sysroot/usr
rsync -avz -e "ssh -p 13377" [email protected]:/opt/vc sysroot/opt
rsync -avz -e "ssh -p 13377" [email protected]:/usr/local/include sysroot/usr/local
rsync -avz -e "ssh -p 13377" [email protected]:/usr/local/lib sysroot/usr/local
$ ./rsync.sh
$ git clone https://github.com/raspberrypi/tools
$ wget https://raw.githubusercontent.com/riscv/riscv-poky/priv-1.10/scripts/sysroot-relativelinks.py
$ chmod +x sysroot-relativelinks.py
$ ./sysroot-relativelinks.py sysroot
/!\ This guide has only been tested with Qt version 5.11.3
$ wget http://download.qt.io/official_releases/qt/5.11/5.11.3/single/qt-everywhere-src-5.11.3.tar.xz
$ tar xf qt-everywhere-src-5.11.3.tar.xz
$ mv qt-everywhere-src-5.11.3 qt-src
Paste the following bash script into a named file configure.sh (configure Qt to be cross compiled)
#!/bin/bash
~/rpi/qt-src/configure \
-release \
-platform linux-g++ \
-device linux-rasp-pi3-g++ \
-device-option CROSS_COMPILE=~/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- \
-sysroot ~/rpi/sysroot \
-opensource \
-confirm-license \
-prefix /usr/local/qt5 \
-extprefix ~/rpi/qt-build/qt5pi \
-hostprefix ~/rpi/qt-build/qt5 \
-v \
-no-use-gold-linker \
-nomake examples \
-nomake tests \
-no-compile-examples \
-skip qtscript
Paste the following bash script into a named file configure-local.sh (configure Qt to be compiled natively)
#!/bin/bash
~/rpi/qt-src/configure \
-release \
-platform linux-g++ \
-opensource \
-confirm-license \
-prefix /usr/local/qt5 \
-extprefix ~/rpi/qt-build-local/qt5 \
-hostprefix ~/rpi/qt-build-local/qt5 \
-v \
-nomake examples \
-nomake tests \
-no-compile-examples \1
-skip qtscript
$ cd qt-build
$ ./../configure.sh
$ make -j N # N = number of logical CPU core
$ make -j N install
Find a way to transfert the Qt folder ~/rpi/qt-build/qt5pi
to the remote path /usr/local/qt5
, may be with the scp command ?
$ mkdir ~/tmpsymlink
$ cd ~/tmpsymlink
$ ln -s /usr/local/qt5/lib/libQt5*.so.5.11.3 ~/tmpsymlink
$ rename 's/.11.3//;' *
$ mv * /usr/local/qt5/lib/
$ cd
$ rm -R tmpsymlink/
add to /etc/bash.bashrc
the following lines
export PATH=$PATH:/usr/local/qt5/bin
$ cd qt-build-local
$ ./../configure-local.sh
$ make -j N # N = number of logical CPU core
$ make -j N install
/!\ Qt Creator is not provided by the cross-compiled build. Download Qt for linux platform and install Qt Creator from https://www.qt.io/download
/!\ Based on Qt Creator 4.8.0
Go to Tools -> Options -> Devices
Add
Generic Linux Device
Enter IP address, user & password
Finish
Go to Tools -> Options -> Kits -> Compilers
Add
GCC
Compiler path: ~/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-g++
Go to Tools -> Options -> Kits -> Debuggers
Add
~/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gdb
Go to Tools -> Options -> Kits -> Qt Versions
Check if an entry with ~/rpi/qt5/bin/qmake shows up. If not, add it.
Go to Tools -> Options -> Kits -> Kits
Kits
Add
Generic Linux Device
Device: the one we just created
Sysroot: ~/rpi/sysroot
Compiler: the one we just created
Debugger: the one we just created
Qt version: the one we saw under Qt Versions
Qt mkspec: leave empty
Try to compile an example.
Happy coding !
add to /etc/bash.bashrc
the following lines for a display screen with resolution of 1920*1080 (for other resolution do a simple conversion from pixel to millimeter)
export QT_QPA_EGLFS_PHYSICAL_WIDTH=508
export QT_QPA_EGLFS_PHYSICAL_HEIGHT=285.75