Wednesday, May 27, 2020

Build ( Cross Compile ) Qt5.14.2 For Raspberry pi4 (raspbian Buster lite OS)
----------------------------------------------------

download toolchain :
----------------------------------
https://app.box.com/s/f8uksyvam238boo8dnguyin547e9l1gl

or
http://thebugfreeblog.blogspot.com/2019/
and download : Download Linux x64 cross toolchain GCC 8.3.0


Start :
--------------

# Target  Side ( raspbian os )
-------------------------------

# nfs server
sudo apt-get install nfs-kernel-server

# confign nfs server
# add this line to  /etc/exports
/    *(rw,nohide,insecure,no_subtree_check,async,no_root_squash)
service nfs-kernel-server restart

# qtbase
sudo apt-get install libboost1.58-all-dev libudev-dev libinput-dev libts-dev libmtdev-dev libjpeg-dev libfontconfig1-dev libssl-dev libdbus-1-dev libglib2.0-dev libxkbcommon-dev libegl1-mesa-dev libgbm-dev libgles2-mesa-dev mesa-common-dev xcb libxcb-xkb-dev x11-xkb-utils libx11-xcb-dev libxkbcommon-x11-dev libwayland-dev

# qtmultimedia
sudo apt-get install libasound2-dev libpulse-dev gstreamer1.0-omx libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev  gstreamer1.0-alsa

# qtwebengine
sudo apt-get install libvpx-dev libsrtp0-dev libsnappy-dev libnss3-dev

# qtlocation
sudo apt-get install libgeoclue-2-dev libdbus-glib-1-dev libgudev-1.0-dev libbluetooth-dev



# Host Side (ubuntu 64 os)
---------------------------

mkdir /opt/rpi
mkdir /opt/rpi/sysroot
mkdir /lib/arm-linux-gnueabihf

apt-get install nfs-common
mount raspberrypi.local:/ /opt/rpi/sysroot
mount raspberrypi.local:/lib/arm-linux-gnueabihf /lib/arm-linux-gnueabihdf

# extract  ( qt source ) qt-everywhere-src-5.14.2.tar.gz    to    /opt/rpi/qt-everywhere-src-5.14.2
# extract  ( compiler  ) rpi-gcc-8.3.0.tar.gz                to    /opt/rpi/rpi-gcc-8.3.0

cd /opt/rpi/qt-everywhere-src-5.14.2

./configure -release -opengl es2 -device linux-rasp-pi4-v3d-g++ -device-option CROSS_COMPILE=/opt/rpi/rpi-gcc-8.3.0/bin/arm-linux-gnueabihf- -sysroot /opt/rpi/sysroot/ -opensource -confirm-license -make libs -prefix /usr/local/Qt-rasp4-5.14.2 -no-xcb -recheck

make

make install

8 comments:

  1. Thank you for your tutorial, I have spent the previous three weeks trying to find a way to cross compile qt for my raspberry pi 4 (I am using the raspberry pi os lite) I followed all the steps and I got this error can you please help me

    ./configure -release -opengl es2 -device linux-rasp-pi4-v3d-g++ -device-option CROSS_COMPILE=/QT-RPI-4/rpi-gcc-8.3.0/bin/arm-linux-gnueabihf- -sysroot /QT-RPI-4/sysroot/ -opensource -confirm-license -make libs -prefix /usr/local/Qt-rasp4-5.14.2 -no-xcb -recheck
    + cd qtbase
    + /QT-RPI-4/qt-everywhere-src-5.14.2/qtbase/configure -top-level -release -opengl es2 -device linux-rasp-pi4-v3d-g++ -device-option CROSS_COMPILE=/QT-RPI-4/rpi-gcc-8.3.0/bin/arm-linux-gnueabihf- -sysroot /QT-RPI-4/sysroot/ -opensource -confirm-license -make libs -prefix /usr/local/Qt-rasp4-5.14.2 -no-xcb -recheck
    Creating qmake...
    .Done.

    This is the Qt Open Source Edition.

    You have already accepted the terms of the Open Source license.

    Running configuration tests...
    Checking for valid makespec... Note: Also available for Linux: linux-clang linux-icc

    ERROR: Cannot compile a minimal program. The toolchain or QMakeSpec is broken.

    Check config.log for details.

    ReplyDelete
    Replies
    1. did you use this tool chain
      https://app.box.com/s/f8uksyvam238boo8dnguyin547e9l1gl

      Delete
  2. I just wanted to test it on the raspbian buster lite os to see if the problem comes from the raspberry pi os lite
    https://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2020-02-14/ I installed the 2020-02-13-raspbian-buster-lite.zip and didn't work also I got the same error..
    this is my raspberry pi history
    apt-get update
    apt-get update
    apt-get install nfs-kernel-server
    nano /etc/exports // I added this in the end of the file / *(rw,nohide,insecure,no_subtree_check,async,no_root_squash)

    service nfs-kernel-server restart
    touch /test
    sudo apt-get install libboost1.58-all-dev libudev-dev libinput-dev libts-dev libmtdev-dev libjpeg-dev libfontconfig1-dev libssl-dev libdbus-1-dev libglib2.0-dev libxkbcommon-dev libegl1-mesa-dev libgbm-dev libgles2-mesa-dev mesa-common-dev xcb libxcb-xkb-dev x11-xkb-utils libx11-xcb-dev libxkbcommon-x11-dev libwayland-dev

    sudo apt-get install libasound2-dev libpulse-dev gstreamer1.0-omx libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-alsa

    sudo apt-get install libvpx-dev libsrtp0-dev libsnappy-dev libnss3-dev

    sudo apt-get install libgeoclue-2-dev libdbus-glib-1-dev libgudev-1.0-dev libbluetooth-dev

    cp -PR /opt/vc/lib/libbrcmEGL.so /opt/vc/lib/libEGL.so
    cp -PR /opt/vc/lib/libbrcmGLESv2.so /opt/vc/lib/libGLESv2.so
    cp -PR /opt/vc/lib/libbrcmOpenVG.so /opt/vc/lib/libOpenVG.so

    ************** this is my ubuntu history *********
    apt-get install nfs-common
    mkdir /QT-RPI-4
    mkdir /QT-RPI-4/sysroot
    rm -r /lib/arm-linux-gnueabihf/
    mkdir /lib/arm-linux-gnueabihf
    mount raspberrypi.local:/ /QT-RPI-4/sysroot
    cd /QT-RPI-4/sysroot/
    ls
    cd ..
    mkdir sources
    cd sources/
    mv /home/amina/Downloads/rpi-gcc-8.3.0_linux.tar.xz .
    mv /home/amina/Downloads/qt-everywhere-src-5.14.2.tar.xz .
    cd ..
    tar xf ./sources/qt-everywhere-src-5.14.2.tar.xz
    ls
    tar xf ./sources/rpi-gcc-8.3.0_linux.tar.xz
    sync
    ls
    cd qt-everywhere-src-5.14.2/
    ./configure -release -opengl es2 -device linux-rasp-pi4-v3d-g++ -device-option CROSS_COMPILE=/QT-RPI-4/rpi-gcc-8.3.0/bin/arm-linux-gnueabihf- -sysroot /QT-RPI-4/sysroot/ -opensource -confirm-license -make libs -prefix /usr/local/Qt-rasp4-5.14.2 -no-xcb
    ./configure -release -opengl es2 -device linux-rasp-pi4-v3d-g++ -device-option CROSS_COMPILE=/QT-RPI-4/rpi-gcc-8.3.0/bin/arm-linux-gnueabihf- -sysroot /QT-RPI-4/sysroot/ -opensource -confirm-license -make libs -prefix /usr/local/Qt-rasp4-5.14.2 -no-xcb -recheck

    Am I doing something wrong? I really do need to cross compile Qt for my end of studies internship and I tried several methods that didn't work on an os with no x server, https://github.com/PhysicsX/QTonRaspberryPi/blob/main/qt5.14.2onRaspberrypi this one worked but the eglfs was not enable for raspberry I had to use the framebuffer linuxfb to test projects and I couldn't even import QtQuick.Studio.Components 1.0 can you please help me ?

    ReplyDelete
    Replies
    1. I think all steps is right, can you make mae connect to anydesk or teamviewer to check

      Delete
  3. thank you my friend for sharing.

    ReplyDelete
  4. hi i got an error when i did a configure like this:

    ./configure -release -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=/piQt/rpi-gcc-8.3.0/bin/arm-linux-gnueabihf- -sysroot /piQt/sysroot -opensource -confirm-license -skip qtscript -make libs -prefix /usr/local/Qt-rasp3-5.13.2 -no-xcb -recheck
    + cd qtbase
    + /piQt/qt-everywhere-src-5.13.2/qtbase/configure -top-level -release -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=/piQt/rpi-gcc-8.3.0/bin/arm-linux-gnueabihf- -sysroot /piQt/sysroot -opensource -confirm-license -skip qtscript -make libs -prefix /usr/local/Qt-rasp3-5.13.2 -no-xcb -recheck
    Creating qmake...
    .Done.

    This is the Qt Open Source Edition.

    You have already accepted the terms of the Open Source license.

    Running configuration tests...
    Checking for valid makespec... Note: Also available for Linux: linux-clang linux-icc

    ERROR: Cannot compile a minimal program. The toolchain or QMakeSpec is broken.

    Check config.log for details.
    //end
    and i check the config.log i got:
    GNU nano 4.8 config.log
    Command line: -release -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=/piQt/rpi-gcc-8.3.0/bin/arm-linux-gnueabihf- -sysroot /piQt/sysroot -opensource -confirm-lic>
    loaded result for config test config.qtbase.tests.machineTuple
    + /piQt/rpi-gcc-6.3.0/bin/arm-linux-gnueabihf-g++ -dumpmachine
    > arm-linux-gnueabihf
    test config.qtbase.tests.machineTuple succeeded
    executing config test verifyspec
    + cd /piQt/qt-everywhere-src-5.13.2/config.tests/verifyspec && /piQt/qt-everywhere-src-5.13.2/qtbase/bin/qmake "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += share>
    + cd /piQt/qt-everywhere-src-5.13.2/config.tests/verifyspec && MAKEFLAGS= /usr/bin/make clean && MAKEFLAGS= /usr/bin/make
    > rm -f verifyspec.o
    > rm -f *~ core *.core
    > /piQt/rpi-gcc-8.3.0/bin/arm-linux-gnueabihf-g++ -c -pipe -marm -mfpu=vfp -mtune=arm1176jzf-s -march=armv6zk -mabi=aapcs-linux -mfloat-abi=hard --sysroot=/piQt/sysroot -O2 -w -fPIC >
    > /piQt/rpi-gcc-8.3.0/bin/arm-linux-gnueabihf-g++ -mfloat-abi=hard --sysroot=/piQt/sysroot -Wl,-O1 -Wl,-rpath-link,/piQt/sysroot/opt/vc/lib -Wl,-rpath-link,/piQt/sysroot/usr/lib/arm->
    > /piQt/rpi-gcc-8.3.0/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: cannot find /opt/rpi/rpi-gcc-8.3.0/arm-linux-gnueabihf/lib/libc.so.6
    > /piQt/rpi-gcc-8.3.0/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: cannot find /opt/rpi/rpi-gcc-8.3.0/arm-linux-gnueabihf/lib/libc_nonshared.a
    > /piQt/rpi-gcc-8.3.0/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: cannot find /opt/rpi/rpi-gcc-8.3.0/arm-linux-gnueabihf/lib/ld-linux-armhf.so.3
    > collect2: error: ld returned 1 exit status
    > make: *** [Makefile:68: verifyspec] Error 1
    //end
    so how can i fix it? thanks

    ReplyDelete
  5. does this works for raspios buster armhf?

    ReplyDelete