본문 바로가기

언어/QT5

Cross-Compile QT 5.12.5 / Raspberry Pi 4

출처: http://wapel.de/?p=641

 

Cross-Compile QT 5.12.5 / Raspberry Pi 4 – Marc Wapelhorst

[on RPi] Install a bunch of development files (for simplicity we use build-dep, not everything is really needed, but it is easier this way). [on host] Create a sysroot. Using rsync we can properly keep things synchronized in the future as well. [on host] A

wapel.de

Running Raspbian Buster on Raspberry Pi 4:

[on RPi] Install a bunch of development files (for simplicity we use build-dep, not everything is really needed, but it is easier this way).

Edit sources list in /etc/apt/sources.list and uncomment the deb-src line:

sudo nano /etc/apt/sources.list

Update your system and install required libraries:

sudo apt-get update 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

Optional depending on your project:

sudo apt-get install wiringpi libnfc-bin libnfc-dev fonts-texgyre libts-dev

Optional depending if you want to use QtMultimedia:

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] Add pi user to render group

sudo gpasswd -a pi render

 

[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

git clone https://github.com/raspberrypi/tools

 

[on host] Create a sysroot. Using rsync we can properly keep things synchronized in the future as well.

mkdir sysroot sysroot/usr

rsync -avz pi@yourpi:/lib sysroot

rsync -avz pi@yourpi:/usr/include sysroot/usr

rsync -avz pi@yourpi:/usr/lib sysroot/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 sysroot

 

[on host] Get QT (start with qtbase first)

git clone git://code.qt.io/qt/qtbase.git -b 5.12.5 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

If you failed build –>

git clean -dfx

 

[on host] Deploy Qt to the device. We simply sync everything from ~/raspi/qt5pi to the prefix we configured above.

rsync -avz qt5pi pi@yourpi:/usr/local

 

[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

 

[on host] Build other Qt modules as desired, the steps are always the same:

git clone git://code.qt.io/qt/<qt-module>.git -b <qt-version>

cd <qt-module>

~/raspi/qt5/bin/qmake

make

make install

My Modules:

  • qtbase
  • qtxmlpatterns
  • qtsvg
  • qtdeclarative
  • qtimageformats
  • qtgraphicaleffects
  • qtquickcontrols
  • qtquickcontrols2
  • qtvirtualkeyboard
  • qtwebsockets
  • qtwebglplugin
  • qtcharts
  • qtconnectivity
  • qtmultimedia
  • qtlocation

Then deploy new files by running:

rsync -avz qt5pi pi@yourpi:/usr/local

 

Set physical Display size in mm:

sudo nano ~/.profile

# physical display properties

export QT_QPA_EGLFS_PHYSICAL_WIDTH=211

export QT_QPA_EGLFS_PHYSICAL_HEIGHT=127

source .profile

'언어 > QT5' 카테고리의 다른 글

ubuntu qt5.15.2 cross compile  (0) 2021.02.28
Cross-Compiling-Qt-for-Raspberry-Pi-4  (0) 2021.02.22
Cross-compile and deploy Qt 5.12 for Raspberry Pi  (0) 2019.10.15