'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 [email protected]:/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.conf
# qmake configuration for building with arm-linux-gnueabihf-g++
#
MAKEFILE_GENERATOR = UNIX
CONFIG += incremental
QMAKE_INCREMENTAL_STYLE = sublib
include(../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-strip
QMAKE_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 = -lGLESv2
load(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.
Solution 1:[1]
I was running into the same problem, then found this article: https://www.tal.org/tutorials/building-qt-62-raspberry-pi.
Adding options for opengles should fix the problem:
$HOME/qt-cross/qtbase/configure -release -opengl es2 -nomake examples -nomake tests \
-qt-host-path $HOME/qt-host \
-extprefix $HOME/qt6-rpi \
-prefix /usr/local/qt6 \
-- -DCMAKE_TOOLCHAIN_FILE=$HOME/qt-cross/toolchain.cmake \
-- -DQT_FEATURE_opengles2=ON \
-- -DQT_FEATURE_opengles3=ON
Alternatively, you can use CMake directly:
cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DINPUT_opengl=es2 -DQT_BUILD_EXAMPLES=OFF -DQT_BUILD_TESTS=OFF \
-DQT_HOST_PATH=$HOME/qt-host \
-DCMAKE_STAGING_PREFIX=$HOME/qt6-rpi \
-DCMAKE_INSTALL_PREFIX=/usr/local/qt6 \
-DQT_FEATURE_opengles2=ON \
-DQT_FEATURE_opengles3=ON \
-DCMAKE_TOOLCHAIN_FILE=$HOME/qt-cross/toolchain.cmake \
$HOME/qt-cross/qtbase
Note that this uses the default paths described in https://doc-snapshots.qt.io/qt6-dev/configure-linux-device.html; you want to adapt this to your specific situation.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Avdaga |
