Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Crosscompile qt6wayland for aarch64/imx8 using cmake
Forum Updated to NodeBB v4.3 + New Features

Crosscompile qt6wayland for aarch64/imx8 using cmake

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
1 Posts 1 Posters 631 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MAWE
    wrote on 2 Feb 2024, 12:31 last edited by
    #1

    I try to crosscompile qt6 to an imx8 based platform. I add the script/toolchain.cmake/patch file at the end of this post.

    The first steps are working well but when cross building qtwayland I always hit this error message from cmake

    -- The CXX compiler identification is GNU 12.3.0
    -- The C compiler identification is GNU 12.3.0
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Check for working CXX compiler: /home/mweisser/projects/sd/MCP/Devices/MCPJ/../../../../os/toolchain/linux/12/aarch64-gs-linux-gnu/bin/aarch64-gs-linux-gnu-g++ - skipped
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Check for working C compiler: /home/mweisser/projects/sd/MCP/Devices/MCPJ/../../../../os/toolchain/linux/12/aarch64-gs-linux-gnu/bin/aarch64-gs-linux-gnu-gcc - skipped
    -- Detecting C compile features
    -- Detecting C compile features - done
    CMake Error at CMakeLists.txt:16 (find_package):
      Could not find a package configuration file provided by "Qt6" (requested
      version 6.6.1) with any of the following names:
    
        Qt6Config.cmake
        qt6-config.cmake
    
      Add the installation prefix of "Qt6" to CMAKE_PREFIX_PATH or set "Qt6_DIR"
      to a directory containing one of the above files.  If "Qt6" provides a
      separate development package or SDK, be sure it has been installed.
    

    Is anyone out there who was able to compile a qt submodule using cmake? I tried a lot of approaches found here and on the web like
    https://forum.qt.io/topic/139492/qt6-cross-compile-for-imx6-with-wayland-support
    https://wiki.qt.io/Cross-Compile_Qt_6_for_Raspberry_Pi
    https://www.tal.org/tutorials/building-qt-65-sub-modules
    but nothing works with sometimes different error messages. Any help would be greatly appreciated.

    This is the script I currently use:

    #!/bin/bash
    
    set -e
    
    BUILDBASE=$HOME/tmp/qt
    mkdir -p $BUILDBASE
    
    export TCBASE=$WORKSPACE/../../../../os/toolchain/linux/12/aarch64-gs-linux-gnu
    export TCSYSROOT=$WORKSPACE/install/linux/armv8/sysroot-imx8x
    
    #cleanup
    if [[ true == true ]]; then
        rm -rf build-* host-qt target-qt qtbase-* qtwayland-*
    fi
    
    #Get the source files
    cd $BUILDBASE
    if [[ true == true ]]; then
    
        if [[ ! -f "qtbase-everywhere-src-6.6.1.tar.xz" ]]; then
            wget https://download.qt.io/official_releases/qt/6.6/6.6.1/submodules/qtbase-everywhere-src-6.6.1.tar.xz    
        fi
        tar xavf qtbase-everywhere-src-6.6.1.tar.xz
        git apply --verbose qt6.patch
    
        if [[ ! -f "qtwayland-everywhere-src-6.6.1.tar.xz" ]]; then
            wget https://download.qt.io/official_releases/qt/6.6/6.6.1/submodules/qtwayland-everywhere-src-6.6.1.tar.xz
        fi
        tar xavf qtwayland-everywhere-src-6.6.1.tar.xz
    fi
    
    
    #Build Qt6 base for host
    cd $BUILDBASE
    if [[ true == true ]]; then
    
        rm -rf build-base-host
        mkdir -p build-base-host
        cd build-base-host
    
        cmake -GNinja \
        -DCMAKE_BUILD_TYPE=Release \
        -DQT_BUILD_EXAMPLES=OFF \
        -DQT_BUILD_TESTS=OFF \
        -DCMAKE_INSTALL_PREFIX=$BUILDBASE/host-qt \
        -S $BUILDBASE/qtbase-everywhere-src-6.6.1
    
        ninja install
    fi
    
    #Build Qt6 wayland for host
    cd $BUILDBASE
    if [[ true == true ]]; then
    
        rm -rf build-wayland-host
        mkdir -p build-wayland-host
        cd build-wayland-host
    
        cmake -GNinja \
        -DCMAKE_INSTALL_PREFIX=$BUILDBASE/host-qt \
        -S $BUILDBASE/qtwayland-everywhere-src-6.6.1
        ninja install
    fi
    
    #Build Qt6 base for target
    cd $BUILDBASE
    if [[ true == true ]]; then
    
        rm -rf build-base-target
        mkdir -p build-base-target
        cd build-base-target
    
        cmake -GNinja \
        -DCMAKE_TOOLCHAIN_FILE=$BUILDBASE/toolchain.cmake \
        -DCMAKE_BUILD_TYPE=Release \
        -DINPUT_opengl=es2 \
        -DFEATURE_vulkan=OFF \
        -DFEATURE_linuxfb=OFF \
        -DFEATURE_eglfs=OFF \
        -DQT_BUILD_EXAMPLES=OFF \
        -DQT_BUILD_TESTS=OFF \
        -DQT_QMAKE_TARGET_MKSPEC=devices/linux-gsimx8x-g++ \
        -DCMAKE_INSTALL_PREFIX=$BUILDBASE/target-qt \
        -DQT_HOST_PATH=$BUILDBASE/host-qt \
        -S $BUILDBASE/qtbase-everywhere-src-6.6.1
        
        ninja install
    fi
    
    #Build Qt6 wayland for target
    cd $BUILDBASE
    if [[ true == true ]]; then
    
        rm -rf build-wayland-target
        mkdir -p build-wayland-target
        cd build-wayland-target
    
        cmake -GNinja \
        -DCMAKE_TOOLCHAIN_FILE=$BUILDBASE/toolchain.cmake \
        -DCMAKE_INSTALL_PREFIX=$BUILDBASE/target-qt \
        -DQT_HOST_PATH=$BUILDBASE/host-qt \
        -S $BUILDBASE/qtwayland-everywhere-src-6.6.1
        ninja install
    fi
    

    This the toolchain.cmake file

    set(CMAKE_SYSTEM_NAME Linux)
    set(CMAKE_SYSTEM_PROCESSOR aarch64)
    set(CMAKE_C_COMPILER $ENV{TCBASE}/bin/aarch64-gs-linux-gnu-gcc)
    set(CMAKE_CXX_COMPILER $ENV{TCBASE}/bin/aarch64-gs-linux-gnu-g++)
    set(CMAKE_SYSROOT $ENV{TCSYSROOT})
    set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
    set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
    set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
    set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
    

    And this my patch for the device support

    diff -N -u -r diff/qtbase-everywhere-src-6.6.1/mkspecs/devices/linux-gsimx8x-g++/qmake.conf src/qtbase-everywhere-src-6.6.1/mkspecs/devices/linux-gsimx8x-g++/qmake.conf
    --- diff/qtbase-everywhere-src-6.6.1/mkspecs/devices/linux-gsimx8x-g++/qmake.conf	1970-01-01 01:00:00.000000000 +0100
    +++ src/qtbase-everywhere-src-6.6.1/mkspecs/devices/linux-gsimx8x-g++/qmake.conf	2023-03-13 16:30:35.102872758 +0100
    @@ -0,0 +1,37 @@
    +#
    +# qmake configuration for the NXP i.MX8 based boards (64-bit)
    +#
    +# The configuration below is set up for running with the fbdev-style
    +# Vivante graphics stack. (so eglfs with the eglfs_viv backend, no
    +# direct drm use via eglfs_kms)
    +
    +# Wayland should also be functional. However, when writing Wayland
    +# *compositors* with Qt, the eglfs backend will have to be switched to
    +# eglfs_viv_wl by setting the QT_QPA_EGLFS_INTEGRATION environment
    +# variable.
    +#
    +# Below is an example configure line that assumes there is an AArch64
    +# toolchain and sysroot available in $HOME/imx8. On device Qt is
    +# expected to be placed under /usr/local/qt514 whereas on the host
    +# 'make install' will copy the host tools and the target libraries to
    +# $HOME/imx8/qt5.
    +#
    +# ./configure -release -opengl es2 -device linux-imx8-g++ \
    +#   -device-option CROSS_COMPILE=~/imx8/toolchain/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux- \
    +#   -sysroot ~/imx8/sysroot \
    +#   -opensource -confirm-license -make libs -prefix /usr/local/qt514 -extprefix ~/imx8/qt5 -v
    +
    +include(../common/linux_device_pre.conf)
    +
    +QMAKE_LIBS_EGL         += -lEGL
    +QMAKE_LIBS_OPENGL_ES2  += -lGLESv2 -lEGL -lGAL
    +QMAKE_LIBS_OPENVG      += -lOpenVG -lEGL -lGAL
    +
    +QMAKE_CFLAGS           += -march=armv8-a -mtune=cortex-a35 -DLINUX=1 -DEGL_API_FB
    +QMAKE_CXXFLAGS         += -march=armv8-a -mtune=cortex-a35 -DLINUX=1 -DEGL_API_FB
    +
    +DISTRO_OPTS += aarch64
    +
    +include(../common/linux_arm_device_post.conf)
    +
    +load(qt_config)
    diff -N -u -r diff/qtbase-everywhere-src-6.6.1/mkspecs/devices/linux-gsimx8x-g++/qplatformdefs.h src/qtbase-everywhere-src-6.6.1/mkspecs/devices/linux-gsimx8x-g++/qplatformdefs.h
    --- diff/qtbase-everywhere-src-6.6.1/mkspecs/devices/linux-gsimx8x-g++/qplatformdefs.h	1970-01-01 01:00:00.000000000 +0100
    +++ src/qtbase-everywhere-src-6.6.1/mkspecs/devices/linux-gsimx8x-g++/qplatformdefs.h	2023-03-13 16:27:31.874515218 +0100
    @@ -0,0 +1,40 @@
    +/****************************************************************************
    +**
    +** Copyright (C) 2016 The Qt Company Ltd.
    +** Contact: https://www.qt.io/licensing/
    +**
    +** This file is part of the qmake spec of the Qt Toolkit.
    +**
    +** $QT_BEGIN_LICENSE:LGPL$
    +** Commercial License Usage
    +** Licensees holding valid commercial Qt licenses may use this file in
    +** accordance with the commercial license agreement provided with the
    +** Software or, alternatively, in accordance with the terms contained in
    +** a written agreement between you and The Qt Company. For licensing terms
    +** and conditions see https://www.qt.io/terms-conditions. For further
    +** information use the contact form at https://www.qt.io/contact-us.
    +**
    +** GNU Lesser General Public License Usage
    +** Alternatively, this file may be used under the terms of the GNU Lesser
    +** General Public License version 3 as published by the Free Software
    +** Foundation and appearing in the file LICENSE.LGPL3 included in the
    +** packaging of this file. Please review the following information to
    +** ensure the GNU Lesser General Public License version 3 requirements
    +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
    +**
    +** GNU General Public License Usage
    +** Alternatively, this file may be used under the terms of the GNU
    +** General Public License version 2.0 or (at your option) the GNU General
    +** Public license version 3 or any later version approved by the KDE Free
    +** Qt Foundation. The licenses are as published by the Free Software
    +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
    +** included in the packaging of this file. Please review the following
    +** information to ensure the GNU General Public License requirements will
    +** be met: https://www.gnu.org/licenses/gpl-2.0.html and
    +** https://www.gnu.org/licenses/gpl-3.0.html.
    +**
    +** $QT_END_LICENSE$
    +**
    +****************************************************************************/
    +
    +#include "../../linux-g++/qplatformdefs.h"
    
    1 Reply Last reply
    0

    1/1

    2 Feb 2024, 12:31

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved