Qt cross compile raspberry pi zero 2
-
I successfully cpompiled Qt for Pi 4 following the instructions.
https://wiki.qt.io/Cross-Compile_Qt_6_for_Raspberry_PiSince I use an Pi 2 Zero in my application I would like to cross compile for this device. The core uses the same instruction set as the Pi4 (armv8-a), bus has an 32bit OS.
Can I use aarch64-linux-gnu or does it have to be another compiler (arm-linux-gnueabihf)?
I changed -DQT_QMAKE_TARGET_MKSPEC devices/linux-rasp-pi3-g++ but configure failed - OpenGL Test failed.
Did someone tried to crss compile for Pi Zero 2?
-
@Curby HI. to compile for PI Zero 2 you will specify linux-rasp-pi2-g++ as your Device.
When i tried cross compilation for pi 3, i used arm-linux-gnueabihf.Maybe it is also the case for pi2 here.Now if pi 2 Zero has an 32bit Os , you will need to use a 32bit compiler that can compile qt6.Hope it helps -
@Ronel_qtmaster But the Pi2 has a different core than the zero 2. How can that work?
The top of my toolchain.cmake will look like this:
cmake_minimum_required(VERSION 3.18) include_guard(GLOBAL) set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_PROCESSOR arm) set(TARGET_SYSROOT /home/nils/zero-sysroot) set(CMAKE_SYSROOT ${TARGET_SYSROOT}) set(ENV{PKG_CONFIG_PATH} $PKG_CONFIG_PATH:/usr/lib/arm-linux-gnueabihf-gnu/pkgconfig) set(ENV{PKG_CONFIG_LIBDIR} /usr/lib/pkgconfig:/usr/share/pkgconfig/:${TARGET_SYSROOT}/usr/lib/arm-linux-gnueabihf-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 /usr/bin/arm-linux-gnueabihf-gcc-11) set(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabihf-g++-11) 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")