Filter results by

Qt5 Cross-Compile – A710

This guide describes how to cross-compile Qt5 (using version 5.9.2) for ARTIK 710 using Ubuntu 16.04 on your development PC. You have to prepare an ARTIK 710 sysroot to make sure that the compiler can find aarch64 libraries and header files.

Setting Up Build Environment

  1. Set up the build environment on your development PC.

    sudo apt install qemu-user-static git gcc-arm-linux-gnueabihf

    sudo apt install g++-arm-linux-gnueabihf

    sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu

    sudo apt install weston

    sudo apt install qt5-default

    sudo apt install gperf bison

    sudo apt install libdbus-1-dev

    sudo apt install libfreetype6-dev

  2. Download these patch files and copy them into your root directory.

    0001-qtbase-mkspec-add-artik-aarch64-device-conf.patch

    0002-qtbase-mkspec-add-artik-device-conf.patch

  3. Prepare directory structures (assuming the main directory is located in ~/qt5).

    mkdir ~/qt5

    cd ~/qt5

    cp ~/0001-qtbase-mkspec-add-artik-aarch64-device-conf.patch .

    cp ~/0002-qtbase-mkspec-add-artik-device-conf.patch .

  4. Download the Qt5 version 5.9.2 tarball.

    1
     wget http://download.qt.io/official_releases/qt/5.9/5.9.2/single/qt-everywhere-opensource-src-5.9.2.tar.xz
  5. Download the artik710 rootfs tarball from github.

    1
     wget https://github.com/SamsungARTIK/ubuntu-build-service/releases/download/release%2FA710_os_3.0.0/ubuntu-arm-artik710-rootfs-0710GC0F-44U-01Q2-20170830.050001-261eeb92d34a70924e69f8e67a925de6.tar.gz
  6. Make a sysroot that can be emulated by the QEMU user binary.

    1
    2
    3
     mkdir artik710_sysroot
     sudo tar xf ~/qt5/ubuntu-arm-artik710-rootfs-0710GC0F-44U-01Q2-20170830.050001-261eeb92d34a70924e69f8e67a925de6.tar.gz -C ~/qt5/artik710_sysroot
     sudo cp /usr/bin/qemu-aarch64-static ~/qt5/artik710_sysroot/usr/bin
  7. Go into the aarch64 sysroot emulation and set up host name resolution.

    1. Go into the chroot.
      sudo chroot ~/qt5/artik710_sysroot

    2. Add this line into the chroot-ed file /etc/hostsusing your own hostname.
      127.0.0.1 localhost artik _your_hostname_here_

    3. Execute these commands.
      mkdir /mnt/run
      sudo mount -o bind /run /mnt/run
      echo 'nameserver 8.8.4.4' | sudo tee -a /etc/resolv.conf

    4. Leave the chroot to let the changes take effect on the next entry.
      exit

    Search online if needed for additional information about host name resolution within chroot.

  8. Go into the chroot, install Qt5 build-dependent packages, then exit the chroot.
    sudo chroot ~/qt5/artik710_sysroot

    1
    2
    3
    4
    5
    6
    7
    8
     apt-key add /var/lib/apt/keyrings/artik-platform-keyring.gpg
     apt update
     apt upgrade
     locale-gen en_US.UTF-8
     apt install build-essential libfreetype6-dev
     apt install libdbus-1-dev
     apt build-dep qt5-default
     cp -rf /usr/lib/aarch64-linux-gnu/pkgconfig/* /usr/lib/pkgconfig

    exit

  9. Fix symlinks to be recognized from cross compile environments

    1
    2
    3
     wget https://raw.githubusercontent.com/alpqr/fixsymlinks_tx1/master/fixsymlinks.sh
     chmod +x fixsymlinks.sh
     sudo ./fixsymlinks.sh ~/qt5/artik710_sysroot

Compiling Qt5

  1. Extract the Qt5 tarball

    tar xf qt-everywhere-opensource-src-5.9.2.tar.xz

  2. Locate the 0001-… patch to "~/qt5" directory and apply it

    cd qt-everywhere-opensource-src-5.9.2

    patch -p1 < ../0001- {hit tab to autocomplete}

  3. Do likewise with the 0002-… patch.

    patch -p2 < ../0002-{hit tab}

  4. Configure Qt5 compile options.
    If you don't want to compile and include Qt5 examples, also add
                -make libs

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
     ./configure \
         -v \
         -confirm-license \
         -opensource \
         -release \
         -shared \
         -accessibility \
         -glib \
         -optimized-qmake \
         -no-pch \
         -system-sqlite \
         -no-directfb \
         -opengl es2 \
         -eglfs \
         -kms \
         -sysroot ~/qt5/artik710_sysroot/ \
         -device linux-artik-aarch64-g++ \
         -device-option CROSS_COMPILE=aarch64-linux-gnu- \
         -no-use-gold-linker \
         -prefix /usr/local/qt5 \
         -extprefix $(pwd)/../qt_inst
  5. Compile it.

    make -j`nproc`

    If you see this error, just run the make again and it will resolve itself.

    stderr: Package freetype2 was not found in the pkg-config search path. Perhaps you should add the directory containing `freetype2.pc' to the PKG_CONFIG_PATH environment variable\

  6. Install the result. The files will be in your ~/qt5/qt_inst directory.

    make install -j`nproc`

Transferring Generated Binaries

  1. Archive the build results.

    cd ~/qt5/qt_inst
    tar zcf ../qt5_inst.tar.gz *

  2. Send the tarball to your ARTIK 710 board (replace {TARGET_IP} with your own).

    scp ~/qt5/qt5_inst.tar.gz root@{TARGET_IP}:~/

Installing Qt5 Binaries

These steps all take place on your ARTIK board.

  1. Extract the tarball.

    mkdir -p /usr/local/qt5
    tar xf ~/qt5_inst.tar.gz -C /usr/local/qt5

  2. Install Qt5 dependencies. Make sure that your board can access the ARTIK repository because it must download the DRM packages from there.

    apt-key add /var/lib/apt/keyrings/artik-platform-keyring.gpg apt update apt install libharfbuzz0b weston

  3. Install the Mali GPU library.

    dpkg -i opengl-es-mali-utgard-wayland_7.0-2.1_arm64.deb
    apt install -f

  4. Set the Qt5 library path.

    echo /usr/local/qt5/lib | tee /etc/ld.so.conf.d/01-qt5.conf ldconfig

Create a file 'kms.json' in your root directory or elsewhere to hold the configuration parameters.
a) Put the following lines in it, editing out the unneeded display devices.
   UNKNOWN1 refers to the MIPI display.
{
  "device": "/dev/dri/card0",
  "hwcursor": false,
  "outputs": [
    {
    "name": "LVDS1",
    "mode": "1024x600"
    },
    {
    "name": "UNKNOWN1",
    "mode": "1080x1920"
    },
    {
    "name": "HDMI1",
    "mode": "1920x1080"
    }
  ]
}

b) Add these lines to your /etc/profile or other start-up batch file to point Qt to the right parameters. Use the path you chose above for 'kms.json'.
export QT_QPA_PLATFORM=eglfs
export QT_QPA_EGLFS_KMS_CONFIG=~/kms.json

Now, after opening a fresh terminal instance to utilize the new settings, run the webengine example.

cd /usr/local/qt5/examples/webengine/quicknanobrowser

./quicknanobrowser -platform eglfs

Last updated on: