OpenGL error during Qt 6 corss compilation for Raspberry Pi 4
-
I am trying to cross compile Qt 6 for Raspberry Pi 4. Following are the steps I follwed.
installed crosstool-ng and related packages.
took the rpi toolchain from https://github.com/ali1234/rpi-toolchain and build the same.
downloaded the qt 6 source code by following the steps mentioned in https://wiki.qt.io/Building_Qt_6_from_Git.
Compiled qt 6 successfully for the host system (Ubuntu 20.04 LTS).
created a toolchain.cmake:
toolchain.cmake
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)set(tools $HOME/rpi-sdk/toolchain-raspbian--x86_64-arm-linux-gnueabihf)
set(CMAKE_SYSROOT $HOME/rpi-sdk/sysroot)
set(CMAKE_C_COMPILER ${tools}/bin/arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER ${tools}/bin/arm-linux-gnueabihf-g++)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)
using rsync -avz pi@rpi_ip:/lib rsync -avz pi@192.168.0.119:/usr copied the files from target device(rpi 4) to create the sysroot
Got the qt source code and compiled the same for host system (ubunto 20.04) sucessfully.
For rpi cross compilation added folder "linux-arm-gnueabihf-g++" under qtbase/mkspecs and made following changes to qmake.confqmake configuration for building with arm-linux-gnueabihf-g++
MAKEFILE_GENERATOR = UNIX
CONFIG += incremental
QMAKE_INCREMENTAL_STYLE = sublibinclude(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)modifications to g++.conf
QMAKE_CC = arm-linux-gnueabihf-gcc
QMAKE_CXX = arm-linux-gnueabihf-g++
QMAKE_LINK = arm-linux-gnueabihf-g++
QMAKE_LINK_SHLIB = arm-linux-gnueabihf-g++modifications to linux.conf
QMAKE_AR = arm-linux-gnueabihf-ar cqs
QMAKE_OBJCOPY = arm-linux-gnueabihf-objcopy
QMAKE_NM = arm-linux-gnueabihf-nm -P
QMAKE_STRIP = arm-linux-gnueabihf-stripQMAKE_INCDIR_OPENGL = $HOME/rpi-sdk/sysroot/usr/include
QMAKE_LIBDIR_OPENGL = $HOME/rpi-sdk/sysroot/usr/lib/arm-linux-gnueabihf
QMAKE_INCDIR_OPENGL_ES2 = $$QMAKE_INCDIR_OPENGL
QMAKE_LIBDIR_OPENGL_ES2 = $$QMAKE_LIBDIR_OPENGL
QMAKE_LIBS_OPENGL = -lGL
QMAKE_LIBS_OPENGL_ES2 = -lGLESv2load(qt_config)
I can see the opengl libraries under rpi-sdk/sysroot/usr/lib/arm-linux-gnueabihf and rpi-sdk/sysroot/lib/arm-linux-gnueabihf. As per my understanding sysroot/lib is a link to sysroot/usr/lib
Using following command to configure for cross compilation:
qtbase/configure -release -opengl es2 -nomake examples -nomake tests -qt-host-path $HOME/QT_COMPILATION/qt-host -extprefix $HOME/QT_COMPILATION/qt-rpi -prefix $HOME/QT_COMPILATION/qt-rpi -- -DCMAKE_TOOLCHAIN_FILE=$HOME/rpi-sdk/toolchain.cmake -DQT_BUILD_TOOLS_WHEN_CROSSCOMPILING=ON
I am getting following errors:ERROR: The OpenGL functionality tests failed! You might need to modify the include and library search paths by editing QMAKE_INCDIR_OPENGL[_ES2], QMAKE_LIBDIR_OPENGL[_ES2] and QMAKE_LIBS_OPENGL[_ES2] in the mkspec for your platform.
CMake Error at cmake/QtBuildInformation.cmake:72 (message):
Check the configuration messages for an error that has occurred.
Call Stack (most recent call first):
cmake/QtBuildInformation.cmake:10 (qt_configure_print_summary)
cmake/QtBuildInternals/QtBuildInternalsConfig.cmake:365 (qt_print_feature_summary)
CMakeLists.txt:132 (qt_build_repo_end)
Please let me know if anything wrong I am doing here.