Qt 6.5.1 Cross Compile - macOS host, Raspberry Pi 4 64-bit target
-
Hello all -
I'm hoping one of the amazing experts here can help out. I've been trying to cross compile Qt 6.5(.1) for RPI4 64bit target with macOS as the host for some time and keep bumping into an issue that I can't figure out. First the system(s) details:
Host:
macOS Ventura 13.4
crosstool-ng 1.25 aarch64-rpi4-linux-gnu cross-compiler (gcc 11.2 based).Target:
Currently Ubuntu 22.04 Raspberry Pi
[I've also tried Official Raspberry Pi OS 64 bit as well]I'm mostly following this tutorial.
I can build Qt for the host, no problem but can't get past the configure stage for the target. Technically it configures, but can't generate build files. Here's the actual error output:
CMake Error at qtbase/src/gui/CMakeLists.txt:337 (target_link_libraries): Target "Gui" links to: GLESv2::GLESv2 but the target was not found. Possible reasons include: * There is a typo in the target name. * A find_package call is missing for an IMPORTED target. * An ALIAS target is missing. CMake Error at qtbase/cmake/QtTargetHelpers.cmake:146 (target_link_libraries): Target "QGstreamerMediaPlugin" links to: EGL::EGL but the target was not found. Possible reasons include: * There is a typo in the target name. * A find_package call is missing for an IMPORTED target. * An ALIAS target is missing.
The configure command I'm using is:
../qt5/configure -release -nomake examples -nomake tests -qt-host-path /Volumes/crosstool-ng/qt-host -extprefix /Volumes/crosstool-ng/qt-raspi -prefix /usr/local/qt6 -device linux-rasp-pi4-aarch64 -device-option CROSS_COMPILE=aarch64-linux-gnu- -sysroot /Volumes/crosstool-ng/rpi-sysroot -- -DCMAKE_TOOLCHAIN_FILE=/Volumes/crosstool-ng/toolchain.cmake -DQT_FEATURE_opengles2=ON -DQT_FEATURE_opengles3=ON
And my
toolchain.cmake
:cmake_minimum_required(VERSION 3.18) include_guard(GLOBAL) set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_PROCESSOR arm) set(TARGET_SYSROOT /Volumes/crosstool-ng/rpi-sysroot) set(CMAKE_SYSROOT ${TARGET_SYSROOT}) set(ENV{PKG_CONFIG_PATH} $PKG_CONFIG_PATH:/usr/lib/aarch64-linux-gnu/pkgconfig) set(ENV{PKG_CONFIG_LIBDIR} /usr/lib/pkgconfig:/usr/share/pkgconfig/:${TARGET_SYSROOT}/usr/lib/aarch64-linux-gnu/pkgconfig:${TARGET_SYSROOT}/usr/lib/pkgconfig) set(ENV{PKG_CONFIG_SYSROOT_DIR} ${CMAKE_SYSROOT}) # if you use other version of gcc and g++ than gcc/g++ 9, you must change the following variables set(CMAKE_C_COMPILER /Volumes/crosstool-ng/aarch64-rpi4-linux-gnu/bin/aarch64-rpi4-linux-gnu-gcc) set(CMAKE_CXX_COMPILER /Volumes/crosstool-ng/aarch64-rpi4-linux-gnu/bin/aarch64-rpi4-linux-gnu-g++) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${TARGET_SYSROOT}/usr/include") set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") set(QT_COMPILER_FLAGS "-march=armv8-a") set(QT_COMPILER_FLAGS_RELEASE "-O2 -pipe") set(QT_LINKER_FLAGS "-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed") 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) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) set(CMAKE_BUILD_RPATH ${TARGET_SYSROOT}) include(CMakeInitializeConfigs) function(cmake_initialize_per_config_variable _PREFIX _DOCSTRING) if (_PREFIX MATCHES "CMAKE_(C|CXX|ASM)_FLAGS") set(CMAKE_${CMAKE_MATCH_1}_FLAGS_INIT "${QT_COMPILER_FLAGS}") foreach (config DEBUG RELEASE MINSIZEREL RELWITHDEBINFO) if (DEFINED QT_COMPILER_FLAGS_${config}) set(CMAKE_${CMAKE_MATCH_1}_FLAGS_${config}_INIT "${QT_COMPILER_FLAGS_${config}}") endif() endforeach() endif() if (_PREFIX MATCHES "CMAKE_(SHARED|MODULE|EXE)_LINKER_FLAGS") foreach (config SHARED MODULE EXE) set(CMAKE_${config}_LINKER_FLAGS_INIT "${QT_LINKER_FLAGS}") endforeach() endif() _cmake_initialize_per_config_variable(${ARGV}) endfunction() set(XCB_PATH_VARIABLE ${TARGET_SYSROOT}) set(GL_INC_DIR ${TARGET_SYSROOT}/usr/include) set(GL_LIB_DIR ${TARGET_SYSROOT}:${TARGET_SYSROOT}/usr/lib/aarch64-linux-gnu/:${TARGET_SYSROOT}/usr:${TARGET_SYSROOT}/usr/lib) set(EGL_INCLUDE_DIR ${GL_INC_DIR}) set(EGL_LIBRARY ${XCB_PATH_VARIABLE}/usr/lib/aarch64-linux-gnu/libEGL.so) set(OPENGL_INCLUDE_DIR ${GL_INC_DIR}) set(OPENGL_opengl_LIBRARY ${XCB_PATH_VARIABLE}/usr/lib/aarch64-linux-gnu/libOpenGL.so) set(GLESv2_INCLUDE_DIR ${GL_INC_DIR}) set(GLIB_LIBRARY ${XCB_PATH_VARIABLE}/usr/lib/aarch64-linux-gnu/libGLESv2.so) set(GLESv2_INCLUDE_DIR ${GL_INC_DIR}) set(GLESv2_LIBRARY ${XCB_PATH_VARIABLE}/usr/lib/aarch64-linux-gnu/libGLESv2.so) set(gbm_INCLUDE_DIR ${GL_INC_DIR}) set(gbm_LIBRARY ${XCB_PATH_VARIABLE}/usr/lib/aarch64-linux-gnu/libgbm.so) set(Libdrm_INCLUDE_DIR ${GL_INC_DIR}) set(Libdrm_LIBRARY ${XCB_PATH_VARIABLE}/usr/lib/aarch64-linux-gnu/libdrm.so) set(XCB_XCB_INCLUDE_DIR ${GL_INC_DIR}) set(XCB_XCB_LIBRARY ${XCB_PATH_VARIABLE}/usr/lib/aarch64-linux-gnu/libxcb.so)
Now here's where it gets interesting. The EGL and GLESv2 tests are failing. Relevant output from
CMakeConfigureLog.yaml
:kind: "try_compile-v1" backtrace: - "/opt/homebrew/Cellar/cmake/3.26.4/share/cmake/Modules/Internal/CheckSourceCompiles.cmake:101 (try_compile)" - "/opt/homebrew/Cellar/cmake/3.26.4/share/cmake/Modules/CheckCXXSourceCompiles.cmake:76 (cmake_check_source_compiles)" - "qtbase/cmake/3rdparty/extra-cmake-modules/find-modules/FindEGL.cmake:127 (check_cxx_source_compiles)" - "qtbase/cmake/QtFindPackageHelpers.cmake:144 (find_package)" - "qtbase/src/gui/configure.cmake:35 (qt_find_package)" - "qtbase/cmake/QtFeature.cmake:592 (include)" - "qtbase/src/CMakeLists.txt:13 (qt_feature_evaluate_features)" directories: source: "/Volumes/crosstool-ng/qtpi-build/CMakeFiles/CMakeScratch/TryCompile-FPtzzd" binary: "/Volumes/crosstool-ng/qtpi-build/CMakeFiles/CMakeScratch/TryCompile-FPtzzd" cmakeVariables: CMAKE_CXX_FLAGS: " -I/Volumes/crosstool-ng/rpi-sysroot/usr/include" CMAKE_CXX_FLAGS_DEBUG: "-g" CMAKE_CXX_LINK_NO_PIE_SUPPORTED: "1" CMAKE_C_LINK_NO_PIE_SUPPORTED: "1" CMAKE_EXE_LINKER_FLAGS: "-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed" CMAKE_MODULE_PATH: "/Volumes/crosstool-ng/qt5/qtbase/cmake;/Volumes/crosstool-ng/qt5/qtbase/cmake/3rdparty/extra-cmake-modules/find-modules;/Volumes/crosstool-ng/qt5/qtbase/cmake/3rdparty/kwin;/Volumes/cro$ CMAKE_OSX_DEPLOYMENT_TARGET: "11.0" CMAKE_POSITION_INDEPENDENT_CODE: "ON" CMAKE_SYSROOT: "/Volumes/crosstool-ng/rpi-sysroot" buildResult: variable: "HAVE_EGL" cached: true stdout: | Change Dir: /Volumes/crosstool-ng/qtpi-build/CMakeFiles/CMakeScratch/TryCompile-FPtzzd Run Build Command(s):/opt/homebrew/bin/ninja -v cmTC_31d7f && [1/2] /Volumes/crosstool-ng/aarch64-rpi4-linux-gnu/bin/aarch64-rpi4-linux-gnu-g++ --sysroot=/Volumes/crosstool-ng/rpi-sysroot -DHAVE_EGL -I/$ [2/2] : && /Volumes/crosstool-ng/aarch64-rpi4-linux-gnu/bin/aarch64-rpi4-linux-gnu-g++ --sysroot=/Volumes/crosstool-ng/rpi-sysroot -I/Volumes/crosstool-ng/rpi-sysroot/usr/include -Wl,-O1 -Wl,--hash-style$ FAILED: cmTC_31d7f : && /Volumes/crosstool-ng/aarch64-rpi4-linux-gnu/bin/aarch64-rpi4-linux-gnu-g++ --sysroot=/Volumes/crosstool-ng/rpi-sysroot -I/Volumes/crosstool-ng/rpi-sysroot/usr/include -Wl,-O1 -Wl,--hash-style=gnu $ /Volumes/crosstool-ng/aarch64-rpi4-linux-gnu/lib/gcc/aarch64-rpi4-linux-gnu/11.2.0/../../../../aarch64-rpi4-linux-gnu/bin/ld.bfd: warning: libGLdispatch.so.0, needed by /Volumes/crosstool-ng/rpi-sysroot/$ /Volumes/crosstool-ng/aarch64-rpi4-linux-gnu/lib/gcc/aarch64-rpi4-linux-gnu/11.2.0/../../../../aarch64-rpi4-linux-gnu/bin/ld.bfd: /Volumes/crosstool-ng/rpi-sysroot/usr/lib/aarch64-linux-gnu/libEGL.so: un$ /Volumes/crosstool-ng/aarch64-rpi4-linux-gnu/lib/gcc/aarch64-rpi4-linux-gnu/11.2.0/../../../../aarch64-rpi4-linux-gnu/bin/ld.bfd: /Volumes/crosstool-ng/rpi-sysroot/usr/lib/aarch64-linux-gnu/libEGL.so: un$ /Volumes/crosstool-ng/aarch64-rpi4-linux-gnu/lib/gcc/aarch64-rpi4-linux-gnu/11.2.0/../../../../aarch64-rpi4-linux-gnu/bin/ld.bfd: /Volumes/crosstool-ng/rpi-sysroot/usr/lib/aarch64-linux-gnu/libEGL.so: un$ /Volumes/crosstool-ng/aarch64-rpi4-linux-gnu/lib/gcc/aarch64-rpi4-linux-gnu/11.2.0/../../../../aarch64-rpi4-linux-gnu/bin/ld.bfd: /Volumes/crosstool-ng/rpi-sysroot/usr/lib/aarch64-linux-gnu/libEGL.so: un$ /Volumes/crosstool-ng/aarch64-rpi4-linux-gnu/lib/gcc/aarch64-rpi4-linux-gnu/11.2.0/../../../../aarch64-rpi4-linux-gnu/bin/ld.bfd: /Volumes/crosstool-ng/rpi-sysroot/usr/lib/aarch64-linux-gnu/libEGL.so: un$ /Volumes/crosstool-ng/aarch64-rpi4-linux-gnu/lib/gcc/aarch64-rpi4-linux-gnu/11.2.0/../../../../aarch64-rpi4-linux-gnu/bin/ld.bfd: /Volumes/crosstool-ng/rpi-sysroot/usr/lib/aarch64-linux-gnu/libEGL.so: un$ /Volumes/crosstool-ng/aarch64-rpi4-linux-gnu/lib/gcc/aarch64-rpi4-linux-gnu/11.2.0/../../../../aarch64-rpi4-linux-gnu/bin/ld.bfd: /Volumes/crosstool-ng/rpi-sysroot/usr/lib/aarch64-linux-gnu/libEGL.so: un$ /Volumes/crosstool-ng/aarch64-rpi4-linux-gnu/lib/gcc/aarch64-rpi4-linux-gnu/11.2.0/../../../../aarch64-rpi4-linux-gnu/bin/ld.bfd: /Volumes/crosstool-ng/rpi-sysroot/usr/lib/aarch64-linux-gnu/libEGL.so: un$ /Volumes/crosstool-ng/aarch64-rpi4-linux-gnu/lib/gcc/aarch64-rpi4-linux-gnu/11.2.0/../../../../aarch64-rpi4-linux-gnu/bin/ld.bfd: /Volumes/crosstool-ng/rpi-sysroot/usr/lib/aarch64-linux-gnu/libEGL.so: un$ /Volumes/crosstool-ng/aarch64-rpi4-linux-gnu/lib/gcc/aarch64-rpi4-linux-gnu/11.2.0/../../../../aarch64-rpi4-linux-gnu/bin/ld.bfd: /Volumes/crosstool-ng/rpi-sysroot/usr/lib/aarch64-linux-gnu/libEGL.so: un$ /Volumes/crosstool-ng/aarch64-rpi4-linux-gnu/lib/gcc/aarch64-rpi4-linux-gnu/11.2.0/../../../../aarch64-rpi4-linux-gnu/bin/ld.bfd: /Volumes/crosstool-ng/rpi-sysroot/usr/lib/aarch64-linux-gnu/libEGL.so: un$ /Volumes/crosstool-ng/aarch64-rpi4-linux-gnu/lib/gcc/aarch64-rpi4-linux-gnu/11.2.0/../../../../aarch64-rpi4-linux-gnu/bin/ld.bfd: /Volumes/crosstool-ng/rpi-sysroot/usr/lib/aarch64-linux-gnu/libEGL.so: un$ /Volumes/crosstool-ng/aarch64-rpi4-linux-gnu/lib/gcc/aarch64-rpi4-linux-gnu/11.2.0/../../../../aarch64-rpi4-linux-gnu/bin/ld.bfd: /Volumes/crosstool-ng/rpi-sysroot/usr/lib/aarch64-linux-gnu/libEGL.so: un$ collect2: error: ld returned 1 exit status ninja: build stopped: subcommand failed. exitCode: 1 ... kind: "try_compile-v1" backtrace: - "/opt/homebrew/Cellar/cmake/3.26.4/share/cmake/Modules/Internal/CheckSourceCompiles.cmake:101 (try_compile)" - "/opt/homebrew/Cellar/cmake/3.26.4/share/cmake/Modules/CheckCXXSourceCompiles.cmake:76 (cmake_check_source_compiles)" - "qtbase/cmake/FindGLESv2.cmake:27 (check_cxx_source_compiles)" - "qtbase/cmake/QtFindPackageHelpers.cmake:144 (find_package)" - "qtbase/src/gui/configure.cmake:58 (qt_find_package)" - "qtbase/cmake/QtFeature.cmake:592 (include)" - "qtbase/src/CMakeLists.txt:13 (qt_feature_evaluate_features)" directories: source: "/Volumes/crosstool-ng/qtpi-build/CMakeFiles/CMakeScratch/TryCompile-661qoh" binary: "/Volumes/crosstool-ng/qtpi-build/CMakeFiles/CMakeScratch/TryCompile-661qoh" cmakeVariables: CMAKE_CXX_FLAGS: " -I/Volumes/crosstool-ng/rpi-sysroot/usr/include" CMAKE_CXX_FLAGS_DEBUG: "-g" CMAKE_CXX_LINK_NO_PIE_SUPPORTED: "1" CMAKE_C_LINK_NO_PIE_SUPPORTED: "1" CMAKE_EXE_LINKER_FLAGS: "-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed" CMAKE_MODULE_PATH: "/Volumes/crosstool-ng/qt5/qtbase/cmake;/Volumes/crosstool-ng/qt5/qtbase/cmake/3rdparty/extra-cmake-modules/find-modules;/Volumes/crosstool-ng/qt5/qtbase/cmake/3rdparty/kwin;/Volumes/cro$ CMAKE_OSX_DEPLOYMENT_TARGET: "11.0" CMAKE_POSITION_INDEPENDENT_CODE: "ON" CMAKE_SYSROOT: "/Volumes/crosstool-ng/rpi-sysroot" buildResult: variable: "HAVE_GLESv2" cached: true stdout: | Change Dir: /Volumes/crosstool-ng/qtpi-build/CMakeFiles/CMakeScratch/TryCompile-661qoh Run Build Command(s):/opt/homebrew/bin/ninja -v cmTC_b256d && [1/2] /Volumes/crosstool-ng/aarch64-rpi4-linux-gnu/bin/aarch64-rpi4-linux-gnu-g++ --sysroot=/Volumes/crosstool-ng/rpi-sysroot -DHAVE_GLESv2 $ [2/2] : && /Volumes/crosstool-ng/aarch64-rpi4-linux-gnu/bin/aarch64-rpi4-linux-gnu-g++ --sysroot=/Volumes/crosstool-ng/rpi-sysroot -I/Volumes/crosstool-ng/rpi-sysroot/usr/include -Wl,-O1 -Wl,--hash-style$ FAILED: cmTC_b256d : && /Volumes/crosstool-ng/aarch64-rpi4-linux-gnu/bin/aarch64-rpi4-linux-gnu-g++ --sysroot=/Volumes/crosstool-ng/rpi-sysroot -I/Volumes/crosstool-ng/rpi-sysroot/usr/include -Wl,-O1 -Wl,--hash-style=gnu $ /Volumes/crosstool-ng/aarch64-rpi4-linux-gnu/lib/gcc/aarch64-rpi4-linux-gnu/11.2.0/../../../../aarch64-rpi4-linux-gnu/bin/ld.bfd: warning: libGLdispatch.so.0, needed by /Volumes/crosstool-ng/rpi-sysroot/$ /Volumes/crosstool-ng/aarch64-rpi4-linux-gnu/lib/gcc/aarch64-rpi4-linux-gnu/11.2.0/../../../../aarch64-rpi4-linux-gnu/bin/ld.bfd: /Volumes/crosstool-ng/rpi-sysroot/usr/lib/aarch64-linux-gnu/libGLESv2.so:$ /Volumes/crosstool-ng/aarch64-rpi4-linux-gnu/lib/gcc/aarch64-rpi4-linux-gnu/11.2.0/../../../../aarch64-rpi4-linux-gnu/bin/ld.bfd: /Volumes/crosstool-ng/rpi-sysroot/usr/lib/aarch64-linux-gnu/libGLESv2.so:$ /Volumes/crosstool-ng/aarch64-rpi4-linux-gnu/lib/gcc/aarch64-rpi4-linux-gnu/11.2.0/../../../../aarch64-rpi4-linux-gnu/bin/ld.bfd: /Volumes/crosstool-ng/rpi-sysroot/usr/lib/aarch64-linux-gnu/libGLESv2.so:$ /Volumes/crosstool-ng/aarch64-rpi4-linux-gnu/lib/gcc/aarch64-rpi4-linux-gnu/11.2.0/../../../../aarch64-rpi4-linux-gnu/bin/ld.bfd: /Volumes/crosstool-ng/rpi-sysroot/usr/lib/aarch64-linux-gnu/libGLESv2.so:$ /Volumes/crosstool-ng/aarch64-rpi4-linux-gnu/lib/gcc/aarch64-rpi4-linux-gnu/11.2.0/../../../../aarch64-rpi4-linux-gnu/bin/ld.bfd: /Volumes/crosstool-ng/rpi-sysroot/usr/lib/aarch64-linux-gnu/libGLESv2.so:$ /Volumes/crosstool-ng/aarch64-rpi4-linux-gnu/lib/gcc/aarch64-rpi4-linux-gnu/11.2.0/../../../../aarch64-rpi4-linux-gnu/bin/ld.bfd: /Volumes/crosstool-ng/rpi-sysroot/usr/lib/aarch64-linux-gnu/libGLESv2.so:$ collect2: error: ld returned 1 exit status ninja: build stopped: subcommand failed. exitCode: 1
The linker can't find
libGLdispatch.so.0
, but it's there:andy@andys-Virtual-Machine crosstool-ng % ls rpi-sysroot/usr/lib/aarch64-linux-gnu/libGLdispatch.so.0 rpi-sysroot/usr/lib/aarch64-linux-gnu/libGLdispatch.so.0 andy@andys-Virtual-Machine crosstool-ng % file rpi-sysroot/usr/lib/aarch64-linux-gnu/libGLdispatch.so.0 rpi-sysroot/usr/lib/aarch64-linux-gnu/libGLdispatch.so.0: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, BuildID[sha1]=158790a1f272c2660ac1e4e757f0d96bf533d68c, stripped
Along with
libEGL.so
andlibGLESv2.so
andy@andys-Virtual-Machine crosstool-ng % ls rpi-sysroot/usr/lib/aarch64-linux-gnu/libEGL* rpi-sysroot/usr/lib/aarch64-linux-gnu/libEGL.so rpi-sysroot/usr/lib/aarch64-linux-gnu/libEGL.so.1.1.0 rpi-sysroot/usr/lib/aarch64-linux-gnu/libEGL_mesa.so.0.0.0 rpi-sysroot/usr/lib/aarch64-linux-gnu/libEGL.so.1 rpi-sysroot/usr/lib/aarch64-linux-gnu/libEGL_mesa.so.0 andy@andys-Virtual-Machine crosstool-ng % ls rpi-sysroot/usr/lib/aarch64-linux-gnu/libGLES* rpi-sysroot/usr/lib/aarch64-linux-gnu/libGLESv1_CM.so rpi-sysroot/usr/lib/aarch64-linux-gnu/libGLESv1_CM.so.1.2.0 rpi-sysroot/usr/lib/aarch64-linux-gnu/libGLESv2.so.2 rpi-sysroot/usr/lib/aarch64-linux-gnu/libGLESv1_CM.so.1 rpi-sysroot/usr/lib/aarch64-linux-gnu/libGLESv2.so rpi-sysroot/usr/lib/aarch64-linux-gnu/libGLESv2.so.2.1.0
No matter what I do, I can't coax the toolchain to find
libGLdispatch
. I've tried somerpath
andrpath-link
switches, but since I don't fully understand them, I'm not sure how to tune them to my use case.Thanks for a great forum and I hope that someone can help me out!
Thanks,
Andy -
I dropped down to 6.2.4 as that's the version used in the tutorial and was able to get a build, cross-compile, deploy and running setup working.
I'd like to get 6.5.x running since it's the latest LTS version, but this will do for now.
Does anyone know of anything different from 6.2.4 to 6.5.0 that would cause such an issue?
Thanks,
Andy