Skip to content

presire/Qt6_CrossCompile_for_PinePhone

Repository files navigation

Qt 6 Cross-Compilation for PinePhone

Revision Date : 2023/11/21


Preface

This article is Qt 6.2 Cross-Compile and Remote Debug for PinePhone.
I am building a cross compile environment with Qt 6.2.4 (Manjaro ARM, Mobian).

Here, my Linux PC is SUSE Enterprise 15 and openSUSE 15, my PinePhone (Beta) is Manjaro ARM (Phosh), Mobian (Phosh).
When building Qt, please adapt to each user's environment.

If you use Linaro GCC Toolchain

Linaro offers monthly GNU toolchain integration builds that provide users with a snapshot of upstream builds.
These builds allow developers to immediately test the functionality of pre-built binaries upstream.

Download Linaro GCC ARM Toolchain.
(latest) GCC Tool Chain Link : https://snapshots.linaro.org/gnu-toolchain/

GCC Tool Chain 12.3 Link : https://snapshots.linaro.org/gnu-toolchain/12.3-2023.06-1/aarch64-linux-gnu/

tar xf gcc-linaro-<version>-x86_64_aarch64-linux-gnu.tar.xz

Note 1: To create a project using QtQuick 6 (QML)
In the libstdc++.so.6 of the GCC toolchain, you need to use a libstdc++.so.6 version equivalent to or older than that of the PinePhone OS.
For example, Mobian 12 is GLIBCXX_3.4.30, so you need to use the pre-GCC 12.2 toolchain.

You can check the version of GLIBCXX for PinePhone OS by executing the following command.

# Manjaro
strings /usr/lib/libstdc++.so.6 | grep -E '^GLIBCXX'

# Mobian
strings /usr/lib/aarch64-linux-gnu/libstdc++.so.6 | grep -E '^GLIBCXX'  

Note 2:
If you want to use the latest GCC AArch64 ToolChain,
you need to build GCC yourself by referring to the URL shown below.

https://github.com/presire/How_to_create_GCC_ToolChain_for_PinePhone.git

It is easy to create and is recommended.


1. Qt Source Code Download and etc... (Linux PC)

On a Linux PC, install the following dependency libraries.

    sudo zypper install autoconf automake cmake unzip tar git wget pkg-config \
                        gperf gcc gcc-c++ gawk bison openssl flex figlet pigz \
                        ncurses-devel ncurses5-devel

When cross-compiling with Qt 6, the Qt library for x86 64 is also required.
Therefore, install the Qt libraries for x86 64 using Qt online installer.

You can also build and install the Qt 6 library for x86 64 from Qt 6 source code, but this is not recommended due to the complexity.
Here, Qt library for host PC (x86 64) is install from Qt online installer.

    wget http://download.qt.io/official_releases/online_installers/qt-unified-linux-x64-online.run

Add execute permission to the downloaded file.

    chmod +x qt-unified-linux-x64-online.run

Run the Qt online installer.

    ./qt-unified-linux-x64-online.run

Follow the Qt installation screen to install Qt 6.
Be sure to match the version of Qt 6 you are cross-compiling.


2. Install the necessary dependencies for PinePhone and SSH Setting (PinePhone)

Create a directory for installing Qt libraries on PinePhone.
This directory will be used in the last part of this article.

mkdir -p ~/InstallSoftware/Qt6

Get the latest updates on PinePhone.

# Manjaro  
sudo pacman -Syu  
sudo systemctl reboot  

# Mobian  
sudo apt update  
sudo apt dist-upgrade  
sudo systemctl reboot  

Install SSH server on PinePhone.

# Manjaro  
sudo pacman -S --needed openssh  

# Mobian  
sudo apt install openssh-server  

Configure the SSH Server to start automatically, and start the SSH Server.

# Manjaro  
sudo systemctl enable sshd  
sudo systemctl start  sshd  

# Mobian  
sudo systemctl enable ssh  
sudo systemctl start  ssh  

Install the dependencies required to build the Qt Library.

# Manjaro
sudo pacman -S --needed base-devel util-linux-libs glib2 cmake unzip pkg-config gdb gdb-common gdbm gcc gcc-libs gcc-fortran python3 \
                        gmp libmpc mpfr libisl ccache icu lksctp-tools python-atspi zstd libinput mtdev libevdev libffi pcre pcre2 \
                        libwacom assimp fontconfig dbus dbus-c++ nss libxkbcommon alsa-lib libxinerama xorg-xinput xcb-util-xrm \
                        pugixml libxslt openssl libproxy libb2 lttng-ust libglvnd \
                        wayland wayland-utils wayland-protocols egl-wayland waylandpp waylandpp wlc wayfire glew-wayland glfw-wayland libva1 \
                        mesa mesa-utils glu vulkan-headers  \
                        qt6ct                               \   # Not sure if it's necessary or not.
                        clang llvm                              # If install QtDoc  

# Mobian
sudo apt install  rsync binutils meson ninja-build ffmpeg openvpn network-manager-openvpn network-manager-openvpn-gnome \
                  zip unzip lz4 ccache pkgconf-bin pkg-config libpkgconf3 pkgconf build-essential make cmake gcc gfortran gdb gdbserver \
                  python3 libgtk-3-dev libzstd1 libzstd-dev \
                  libc6 libc6-dev linux-libc-dev glibc-source libc-dev-bin libc-devtools libglib2.0-0 libglib2.0-dev libglib2.0-dev-bin \
                  libgmp-dev libmpc-dev libmpfr-dev libisl-dev gconf2 gconf2-common libgconf2-dev \
                  libdbus-1-3 libdbus-1-dev libdbus-c++-bin libdbus-c++-dev libsctp1 libsctp-dev libatspi2.0-0 libatspi2.0-dev \
                  libinput-bin libinput-dev libts0 libts-bin libts-dev libmtdev1 libmtdev-dev libevdev2 libevdev-dev libicu-dev icu-devtools \
                  libblkid1 libblkid-dev libffi8 libffi-dev libmount1 libmount-dev libudev1 libudev-dev libhd21 libhd-dev libtsm-dev \
                  pcre2-utils libpcre2-32-0 libpcre2-dev libselinux1 libselinux1-dev libsepol2 libsepol-dev libwacom9 libwacom-dev \
                  libproxy-dev liblttng-ust1 liblttng-ust-common1 liblttng-ust-dev libb2-1 libb2-dev libsdl2-dev libsystemd-dev \
                  libfontconfig1 libfontconfig-dev libfontconfig1-dev libjpeg-dev libjpeg62-turbo libjpeg62-turbo-dev libjpeg-dev \
                  libasound2 libasound2-dev \
                  sqlite3 libsqlite3-0 libsqlite3-dev libssl3 libssl-dev libnss3 libnss3-dev libxslt1.1 libxslt1-dev libpugixml1v5 libpugixml-dev \
                  libbz2-dev libatkmm-1.6-dev libsrtp2-dev libsnappy-dev re2c libpoppler-dev libmd4c-dev libmd4c-html0-dev \
                  liblitehtml0 liblitehtml-dev \
                  libxkbcommon-dev libxcb-xinerama0 libxcb-xinerama0-dev libglut3.12 libglut-dev \
                  libwayland-bin libwayland-dev libwayland-egl1 libwayland-egl++1 libwayland-egl1-mesa libwayland-egl-backend-dev \
                  libwayland-client++1 libwayland-client-extra++1 libwayland-cursor++1 wayland-scanner++ wayland-protocols waylandpp-dev \
                  libosmesa6-dev mesa-common-dev libopengl-dev libgl-dev libglm-dev libgl1-mesa-dev libgle3-dev libgles-dev libgles2-mesa-dev \
                  libegl-dev libegl1-mesa-dev libgegl-dev libglu1-mesa libglu1-mesa-dev libglw1-mesa-dev libglfw3-dev libglew-dev libglx-dev \
                  libgbm-dev libdrm-dev libdirectfb-dev \
                  libglvnd-dev libglvnd-core-dev libglut-dev libopenal-dev libalut-dev \
                  libweston-10-0 libweston-10-dev                                      \
                  libvulkan1 libvulkan-dev                                             \  # If you use Vulkan.
                  libclang-dev libclang-cpp-dev llvm-dev                                  # If you use install QDoc, Clang-based lupdate parser.


                  libassimp5 libassimp-dev                                             \  # Currently (2023/11), libassimp-dev is not installed because the search for libdraco library fails,
                                                                                          # when libassimp-dev is installed.
                                                                                          # At that time, AssImp inside Qt is used.
                  libdouble-conversion3 libdouble-conversion-dev                       \  # Currently (2023/11), libdouble-conversion-dev is not installed because the search for double-conversion header files fails,
                                                                                          # when libdouble-conversion-dev is installed.
                                                                                          # At that time, Double-Conversion inside Qt is used

If you want to use other features, you should also install the following dependencies.

Manjaro

  • Bluetooth
    bluez bluez-tools bluez-libs bluez-utils

  • Photo
    openjpeg2 libjpeg-turbo libpng libtiff libmng libwebp

  • Codec
    ffmpeg v4l-utils xvidcore x264 x265

  • Multimedia
    libwmf gstreamer gstreamermm gst-plugins-base gst-plugins-base-libs gst-plugins-good
    gst-plugins-bad gst-plugins-bad-libs gst-plugins-ugly gst-libav gst-plugin-wpe
    gst-plugin-pipewire gst-plugin-gtk qt-gstreamer gst-plugin-qmlgl gst-plugin-opencv

  • ALSA audio
    alsa-lib

  • Pulse audio
    pulseaudio-alsa

  • OpenAL audio
    openal

  • Text to Speech
    flite

  • Qt SerialPort
    libserialport

  • Sensor
    sensorfw

  • Database
    ODBC : unixodbc libiodbc
    PostgreSQL : postgresql-libs libpqxx
    MariaDB : mariadb-clients mariadb-libs
    SQLite : sqlite

  • Printer
    libcups

  • Accessibility
    at-spi2-core at-spi2-atk

  • SCTP
    lksctp-tools
    (To enable this, add the -sctp option when configuring.)

  • Webengine
    Required : flex bison gperf readline nss libdrm
    Option1 : libxml2 libxml++ libxslt minizip jsoncpp lcms2 libevent protobuf protobuf-c
    Option2(Be careful, as it is unstable.) : opus libvpx


Mobian

  • Bluetooth
    bluez bluez-tools libbluetooth-dev

  • Photo
    libjpeg-dev libpng-dev libtiff-dev libmng-dev libwebp-dev

  • Codec
    libavcodec-dev libavformat-dev libavutil-dev libavdevice-dev libavfilter-dev libswscale-dev libswresample-dev
    libpostproc-dev libv4l-dev libxvidcore-dev libx264-dev libx265-dev

  • Multimedia
    libwmf-dev libgstreamer1.0-0 libgstreamer1.0-dev libgstreamermm-1.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-libav gstreamer1.0-pulseaudio gstreamer1.0-tools
    gstreamer1.0-alsa gstreamer1.0-x gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5
    libwayland-dev

  • ALSA audio
    libasound2-dev

  • Pulse audio
    pulseaudio libpulse-dev

  • OpenAL audio
    libopenal-data libopenal1 libopenal-dev libsndio7.0 libsndio-dev

  • Text to Speech
    flite1-dev libspeechd-dev

  • Qt SerialPort
    libserialport-dev

  • Sensor
    Unknown (currently under investigation)

  • Database
    ODBC : unixodbc unixodbc-common unixodbc-dev
    PostgreSQL : libpq-dev
    MariaDB : libmariadbclient-dev
    SQLite : libsqlite3-dev

  • Printer
    libcups2-dev

  • Accessibility
    libatspi2.0-dev

  • SCTP
    libsctp1 libsctp-dev
    (To enable this, add the -sctp option when configuring.)

  • Webengine
    Required : flex bison gperf libre2-dev libnss3-dev libdrm-dev
    Option1 : libxml2-dev libxslt1-dev libminizip-dev libjsoncpp-dev liblcms2-dev libevent-dev libprotobuf-dev protobuf-compiler
    Option2(Be careful, as it is unstable.) : libopus-dev libvpx-dev

  • X11
    libfontconfig-dev libfontconfig1-dev libfreetype6-dev
    libx11-dev libx11-xcb-dev libsm-dev libice-dev
    libxcb1-dev libxext-dev libxi-dev libxcomposite-dev libxcursor-dev libxtst-dev libxrandr-dev
    libxfixes-dev libxrender-dev libxdamage-dev libxkbfile-dev
    libxcb-glx0-dev libxcb-keysyms1-dev libxcb-image0-dev libxcb-shm0-dev libxcb-icccm4-dev libxcb-sync-dev
    libxcb-xfixes0-dev libxcb-shape0-dev libxcb-randr0-dev libxcb-render-util0-dev libxcb-util0-dev
    libxcb-xinerama0-dev libxcb-xkb-dev libxkbcommon-dev libxkbcommon-x11-dev libxcb-damage0-dev
    libxcb-composite0-dev libxcb-record0-dev libxcb-present-dev libxcb-res0-dev libxcb-render0-dev
    libxcb-xinput-dev libxcb-xv0-dev libxcb-xtest0-dev libxcb-cursor-dev libxcb-util-dev libxcb-ewmh-dev libxcb-xvmc0-dev
    libxcb-imdkit-dev
    libxcb-xrm-dev libxcb-dri2-0-dev libxcb-dri3-dev libxcb-dpms0-dev libxcb-xf86dri0-dev


Use the rsync command to synchronize the files between Linux PC and PinePhone.
However, some of the files to be synchronized require root privileges.

Therefore, add the following settings to the /etc/sudoers file so that all files can be synchronized even by ordinary users.
With the following settings, the rsync command will be executed with super user privileges if necessary.

echo "$USER ALL=NOPASSWD:$(which rsync)" | sudo tee --append /etc/sudoer

Restart PinePhone just in case.

sudo shutdown -r now
# or
sudo systemctl reboot


3. Download Qt source code

Qt Everywhere (recommended here)

wget https://download.qt.io/official_releases/qt/6.2/6.2.4/single/qt-everywhere-src-6.2.4.tar.xz  
tar xf qt-everywhere-opensource-src-6.2.4.tar.gz


4. Download the Qt target file from this Github (Linux PC)

In the downloaded and copied qmake.conf.

git clone https://github.com/presire/Qt6_CrossCompile_for_PinePhone.git

cp -r Qt6_CrossCompile_for_PinePhone/linux-pinephone-g++ qt-everywhere-src-6.2.4/qtbase/mkspecs/devices  

Note 1 : for Manjaro ARM
comment DISTRO_OPTS += deb-multi-arch if you want to use Manjaro ARM.

vi qt-everywhere-src-6.2.4/qtbase/mkspecs/devices/linux-pinephone-g++/qmake.conf  

# qt-everywhere-src-6.2.4/qtbase/mkspecs/devices/linux-pinephone-g++/qmake.conf file  

...  

# If you use Manjaro ARM, you need to comment it.  
#DISTRO_OPTS += deb-multi-arch  

...  

Note 2 : for PinePhone Pro
I do not have a PinePhone Pro and have not tried this setup.
If you have tried it, please report back to us.

first, comment COMPILER_FLAGS = -march=armv8-a -mtune=cortex-a53 if you want to use PinePhone Pro.
Next, remove the COMPILER_FLAGS = -march=armv8-a -mtune=cortex-a72 comment to make it effective.

vi qt-everywhere-src-6.2.4/qtbase/mkspecs/devices/linux-pinephone-g++/qmake.conf

# qt-everywhere-src-6.2.4/qtbase/mkspecs/devices/linux-pinephone-g++/qmake.conf file  

...  

# If you use PinePhone Pro, you need to comment it.  
#COMPILER_FLAGS         = -march=armv8-a -mtune=cortex-a53  # for PinePhone Beta  

# If you use PinePhone Pro, you need to remove the comment.  
# Enable this setting.  
COMPILER_FLAGS         = -march=armv8-a -mtune=cortex-a72  # for PinePhone Pro  

...  


5. Download & Install Wayland-Scanner (Linux PC)

You need to install Meson & Ninja for building Wayland-Scanner.

git clone https://github.com/wayland-project/wayland.git  
cd wayland && mkdir build  

meson ./build/ --prefix=<Install Directory for Wayland-Scanner> -Ddocumentation=false  
ninja -C build/ install  

cp /<Install Directory for Wayland-Scanner>/bin/wayland-scanner /<Qt Tool for Linux PC>/bin  


6. Download PinePhone's System Root (Linux PC)

It is necessary to synchronize with the root directory of PinePhone, create the system root directory.

mkdir -p ~/<System Root PinePhone> && \  
         ~/<System Root PinePhone>/usr && \  
         ~/<System Root PinePhone>/usr/share  

rsync -avz --rsync-path="sudo rsync" --delete --rsh="ssh" <PinePhone's User Name>@<PinePhone's IP Address or Host Name>:/lib ~/<System Root PinePhone>/  
rsync -avz --rsync-path="sudo rsync" --delete --rsh="ssh" <PinePhone's User Name>@<PinePhone's IP Address or Host Name>:/usr/lib ~/<System Root PinePhone>/usr  
rsync -avz --rsync-path="sudo rsync" --delete --rsh="ssh" <PinePhone's User Name>@<PinePhone's IP Address or Host Name>:/usr/include ~/<System Root PinePhone>/usr  
rsync -avz --rsync-path="sudo rsync" --delete --rsh="ssh" <PinePhone's User Name>@<PinePhone's IP Address or Host Name>:/usr/share/pkgconfig ~/<System Root PinePhone>/usr/share  

Convert symbolic links of downloaded files and directories from absolute paths to relative paths.

wget https://raw.githubusercontent.com/riscv/riscv-poky/master/scripts/sysroot-relativelinks.py
chmod +x sysroot-relativelinks.py

./sysroot-relativelinks.py <System Root PinePhone>


7. Edit CMake toolchain file

Edit CMake tool chain file to be used in building Qt 6 library for the target.

    vi Qt6ToolChain_for_PinePhone_Manjaro.cmake
    or
    vi Qt6ToolChain_for_PinePhone_Mobian.cmake

  • "TARGET_SYSROOT"
    Specify the system root directory of PinePhone.

  • "CMAKE_C_COMPILER"
    Specify path to cross-compiler. (Ex: /home/user/bin/aarch64-linux-gnu-gcc)

  • "CMAKE_CXX_COMPILER"
    Specify path to cross-compiler. (Ex: /home/user/bin/aarch64-linux-gnu-g++)



8. Build Qt Source Code (Linux PC)

Note When building Qt 6 using GCC 13, the following error may be output.
Bug Report URL : https://bugreports.qt.io/browse/QTBUG-111604?focusedCommentId=718489

error: 'uint32_t' is not a member of 'std'; did you mean 'wint_t'?  

Then, edit the file shown below.

// qt-everywhere-src-6.x.x/qt3d/src/3rdparty/assimp/src/code/AssetLib/FBX/FBXBinaryTokenizer.cpp
// Line 53
// Before.
#include <stdint.h>
// After.
#include <cstdint>


// qt-everywhere-src-6.x.x/qtquick3d/src/3rdparty/assimp/src/code/AssetLib/FBX/FBXBinaryTokenizer.cpp
// Line 53.
// Before.
#include <stdint.h>
// After.
#include <cstdint>


// qt-everywhere-src-6.x.x/qtquick3d/src/3rdparty/assimp/src/code/AssetLib/FBX/FBXTokenizer.cpp
// Line 58.
// Before.
#include <stdint.h>
// After.
#include <cstdint>

Build the Qt source code.

### Manjaro ###

# Set path to Wayland Scanner
export PATH="/<Path to Wayland Scanner>/bin:$PATH"
export LD_LIBRARY_PATH="/<Path to Wayland Scanner>/lib64:$LD_LIBRARY_PATH"

# Set PinePhone's system root directory
export SYSROOT=<PinePhone's system root directory>

# Set Pkg-Config
export PKG_CONFIG_PATH="$SYSROOT/usr/lib/pkgconfig:$SYSROOT/usr/lib/aarch64-linux-gnu/pkgconfig"
export PKG_CONFIG_LIBDIR="$SYSROOT/usr/lib/pkgconfig:$SYSROOT/usr/lib/aarch64-linux-gnu/pkgconfig:$SYSROOT/usr/share/pkgconfig"

# Set Cross-Compiler
export CROSS_COMPILER="/<Path to Cross-Compile's toolchain>/bin/aarch64-linux-gnu-"
# or
# export CROSS_COMPILER="/<Path to Cross-Compile's toolchain>/bin/aarch64-unknown-linux-gnu-"

cmake -G Ninja \
../qt-everywhere-src-6.2.4          \
-DCMAKE_BUILD_TYPE=Release          \
-DINPUT_opengl=es2                  \
-DQT_FEATURE_opengles2=ON           \
-DQT_FEATURE_opengles3=ON           \
-DCMAKE_TOOLCHAIN_FILE=/Path/to/ToolChain_for_PinePhone_Manjaro.cmake \  
-DQT_BUILD_TOOLS_WHEN_CROSSCOMPILING=ON                     \
-DQT_QMAKE_TARGET_MKSPEC=devices/linux-pinephone-g++        \
-DQT_QMAKE_DEVICE_OPTIONS=CROSS_COMPILE=$CROSS_COMPILER     \
-DQT_BUILD_EXAMPLES=OFF  \
-DQT_BUILD_TESTS=OFF     \
-DBUILD_qtdoc=OFF        \  # If not install QtDoc
-DBUILD_qtwebengine=OFF  \  # If not install QtWebEngine
-DBUILD_qtwebview=OFF    \  # If not install QtWebView
-DBUILD_qtwebchannel=OFF \  # If not install QtWebChannel
-DFEATURE_clang=OFF      \  # If not install QtDoc. To "ON" this, Clang/Clang++ is required.
-DFEATURE_clangcpp=OFF   \  # If not install QtDoc. To "ON" this, Clang/Clang++ is required.
-DCMAKE_SYSROOT=$SYSROOT \
-DQT_HOST_PATH=<Path to Qt6 install directory for x86 64  Ex: /home/user/Qt/6.2.4/gcc_64>  \
-DCMAKE_STAGING_PREFIX=<Install Qt6 libraries directory for PinePhone>  \
-DCMAKE_INSTALL_PREFIX=<Qt6 project directory>                          \
-DCMAKE_PREFIX_PATH=$SYSROOT/usr/lib

### Mobian ###

# Set path to Wayland Scanner
export PATH="/<Path to Wayland Scanner>/bin:$PATH"
export LD_LIBRARY_PATH="/<Path to Wayland Scanner>/lib64:$LD_LIBRARY_PATH"

# Set PinePhone's system root directory
export SYSROOT=<PinePhone's system root directory>

# Set Cross-Compiler
export CROSS_COMPILER="/<Path to Cross-Compile's toolchain>/bin/aarch64-linux-gnu-"

cmake -G Ninja \
../qt-everywhere-src-6.2.4          \
-DCMAKE_BUILD_TYPE=Release          \
-DINPUT_opengl=es2                  \
-DQT_FEATURE_opengles2=ON           \
-DQT_FEATURE_opengles3=ON           \
-DQT_QPA_DEFAULT_PLATFORM=wayland   \
-DCMAKE_TOOLCHAIN_FILE=/Path/to/ToolChain_for_PinePhone_Mobian.cmake \  
-DQT_BUILD_TOOLS_WHEN_CROSSCOMPILING=ON                     \
-DQT_QMAKE_TARGET_MKSPEC=devices/linux-pinephone-g++        \
-DQT_QMAKE_DEVICE_OPTIONS=CROSS_COMPILE=$CROSS_COMPILER     \
-DQT_BUILD_EXAMPLES=OFF  \
-DQT_BUILD_TESTS=OFF     \
-DBUILD_qtdoc=OFF        \  # If not install QtDoc
-DBUILD_qtwebengine=OFF  \  # If not install QtWebEngine
-DBUILD_qtwebview=OFF    \  # If not install QtWebView
-DBUILD_qtwebchannel=OFF \  # If not install QtWebChannel
-DFEATURE_clang=OFF      \  # If not install QtDoc. To "ON" this, Clang/Clang++ is required.
-DFEATURE_clangcpp=OFF   \  # If not install QtDoc. To "ON" this, Clang/Clang++ is required.
-DCMAKE_SYSROOT=$SYSROOT \
-DQT_HOST_PATH=<Path to Qt6 install directory for x86 64  Ex: /home/user/Qt/6.2.4/gcc_64>  \
-DCMAKE_STAGING_PREFIX=<Install Qt6 libraries directory for PinePhone>  \
-DCMAKE_INSTALL_PREFIX=<Qt6 project directory>                          \
-DCMAKE_PREFIX_PATH=$SYSROOT/usr/lib/aarch64-linux-gnu

Build and Install.

cmake --build . --parallel $(nproc)
cmake --install .

Go to the cross-compiled Qt 6 installation directory.
Create a symbolic file for the host-qmake file in bin directory.
(in this case, qmake-host file).

    cd <cross-compiled Qt 6 installation directory>
    ln -s host-qmake qmake-host

9. Upload Qt Library (Linux PC)

Deploy the built Qt library to PinePhone.

rsync -avz --rsh="ssh" --delete /<Above, Qt Library for PinePhone>/* \  
<PinePhone's User Name>@<PinePhone's IP Address or Host Name>:/home/<PinePhone's User Name>/InstallSoftware/Qt6  


10. Settings Qt Creator

10.1 Qt Creator General Settings

Launch Qt Creator.

  • Setting up the Qt compiler AArh64 Toolchain.
    Qt Creator - [Tool] - [Option] - [Kits] - [Compiler] -[Add] - [GCC] - [C]
    /<AArch64 Toolchain's Directory>/bin/aarch64-linux-gnu-gcc
    Qt Creator - [Tool] - [Option] - [Kits] - [Compiler] -[Add] - [GCC] - [C++]
    /<AArch64 Toolchain's Directory>/bin/aarch64-linux-gnu-g++

  • Setting up the Qt Debugger AArh64 Toolchain.
    Qt Creator - [Tool] - [Option] - [Kits] - [Debugger] -[Add]
    /<AArch64 Toolchain's Directory>/bin/aarch64-linux-gnu-gdb

  • Setting up the Qt Qmake for Qt Cross-Compile.
    Qt Creator - [Tool] - [Option] - [Kits] - [Qt version] -[Add]
    /<Qt Tool for Linux PC's Directory>/bin/qmake-host

  • Setting up the Qt Qmake for Qt Cross-Compile.
    Qt Creator - [Tool] - [Option] - [Kits] - [Kits] -[Add]
    Compiler : The compiler configured above
    Debugger : The debugger configured above
    Qt version : The Qmake configured above
    Qt mkspec : /<Qt Tool for Linux PC's Directory>/mkspecs/devices/linux-pinephone-g++
    Sysroot(It can be set or unset) : /<System Root PinePhone>

  • Setting Add GDB Start Command.
    Qt Creator - [Tool] - [Option] - [Debugger] - [GDB]Tab
    Additional Startup Commands : set sysroot target:/

  • Setting Kit.

    1. [Kits] on the left of [Preferences] screen - From the [Kits] tab on the right of [Preferences] screen, click the [Add] button.

    2. Select [Remote Linux Device] from [Devices Type] pull-down.

    3. From [Device] pull-down, select target you created in [Device] on the left side of [Preferences] screen.

    4. Select [Local PC] from [Build device] pull-down.

    5. Select AArch64 ToolChain from [Compiler] pull-down.

    6. Select AArch64 GDB from [Debugger] pull-down.

    7. Select Qt 6.2.4 from [Qt version] pull-down.

    8. Select //mkspecs/devices/linux-pinephone-g++ from [Debugger] pull-down.

    9. In [CMake Configuration], click [Change...] button.
      Input the settings shown below. *1

      -DCMAKE_TOOLCHAIN_FILE:UNINITIALIZED=/<Path to Cross-Compiled Qt6 Install directory>/lib/cmake/Qt6/qt.toolchain.cmake

      Press [Apply] button.

      NOTE: *2
      This setting can be set by selecting [Projects] - [Build & Run] - [Build] on the left side screen of Qt Creator.
      It can be set for each project by editing the value of CMAKE_TOOLCHAIN_FILE in [Build Settings] in the right pane of Qt Creator main screen.

      Qt6 Kit settings CMake Configuration *1 CMake Configuration *2


11 Settings Qt Project

Launch Qt Creator and Open, and after create Qt Project.

Qt Creator - [Project] - [Run] - [Run Settings] - [Environment] - [Details] - [Add]
then, Click [Fetch Device Environment]Button.
Be sure to click on [Fetch Device Environment] Button before starting the debugger.

  • Variable - QT_QPA_PLATFORMTHEME
    Value : qt6ct

  • Variable : DISPLAY
    Value : :0 or :0.0

  • Variable : LD_LIBRARY_PATH
    Value : /home/<PinePhone's User Name>/InstallSoftware/Qt6/lib:/home/<PinePhone's User Name>/InstallSoftware/Qt6/plugins/qmltooling

  • Variable : QML_IMPORT_PATH
    Value : /home/<PinePhone's User Name>/InstallSoftware/Qt6/qml

  • Variable : QML2_IMPORT_PATH
    Value : /home/<PinePhone's User Name>/InstallSoftware/Qt6/qml

  • Variable : QT_PLUGIN_PATH
    Value : /home/<PinePhone's User Name>/InstallSoftware/Qt6/plugins

  • Variable : QT_QPA_PLATFORM_PLUGIN_PATH
    Value : /home/<PinePhone's User Name>/InstallSoftware/Qt6/plugins/platforms


If the following error message appears during debugging From the Qt Creator side menu,
select [Project] - [Build & Run] - [Run] - [Command Line Arguments:] and input -platform wayland.

qt.qpa.plugin: Could not load the Qt platform plugin "wayland"  


12. Warning and Error related

12.1 Debug start speed issues

When you debug remote targets, GDB Debugger is looking in the local PinePhone's System-Root directory for the libraries.
So just need to tell GDB Debugger to load the remote PinePhone's System-Root from the remote target.

but, "set sysroot target:/" takes a long time to start debugging,
so writing the following setting will speed up the start of debugging.

First, Create the directories and symbolic links shown below.

mkdir -p /<PinePhone's System-Root Directory>/home/<PinePhone's User Name>/InstallSoftware  
ln -s /<Qt Library for PinePhone> /<PinePhone's System-Root Directory>/home/<PinePhone's User Name>/InstallSoftware  
mv /<PinePhone's System-Root Directory>/home/<PinePhone's User Name>/InstallSoftware/<Qt Library for PinePhone> \  
   /<PinePhone's System-Root Directory>/home/<PinePhone's User Name>/InstallSoftware/Qt6  

Next, Write the following settings.
Qt Creator - [Tool] - [Option] - [Debugger] - [GDB]Tab - [Additional Startup Commands]

set sysroot /<System Root PinePhone>  

Make sure you can debug Qt project.

About

This configuration file and configuration information is completely free, so you can freely modify and upload it.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published