Qt 6.0 build for Raspberry Pi 4 "Opengl functionality tests failed".
-
Hi everyone,
I'm trying to build Qt6 for Raspberry Pi 4, following the Cross-Compile QT6 for Pi4.
I'm using the 64 bit image: raspios_arm64-2022-09-22.
RIght now I'm stucked with this error, can you help-me guys?CMake Error at qtbase/cmake/QtBuildInformation.cmake:490 (message): Feature "opengl": Forcing to "ON" breaks its condition: QT_FEATURE_opengl_desktop OR QT_FEATURE_opengl_dynamic OR QT_FEATURE_opengles2 Condition values dump: QT_FEATURE_opengl_desktop = "OFF" QT_FEATURE_opengl_dynamic = "OFF" QT_FEATURE_opengles2 = "OFF" Call Stack (most recent call first): qtbase/cmake/QtFeature.cmake:281 (qt_configure_add_report_error) qtbase/cmake/QtFeature.cmake:403 (qt_feature_check_and_save_internal_value) qtbase/cmake/QtFeature.cmake:606 (qt_evaluate_feature) qtbase/cmake/QtFeature.cmake:575 (qt_feature_module_end) qtbase/src/CMakeLists.txt:12 (qt_feature_evaluate_features)
ERROR: Feature "opengl": Forcing to "ON" breaks its condition: QT_FEATURE_opengl_desktop OR QT_FEATURE_opengl_dynamic OR QT_FEATURE_opengles2 Condition values dump: QT_FEATURE_opengl_desktop = "OFF" QT_FEATURE_opengl_dynamic = "OFF" QT_FEATURE_opengles2 = "OFF" ERROR: The OpenGL functionality tests failed! You might need to modify the OpenGL package search path by setting the OpenGL_DIR CMake variable to the OpenGL library's installation directory. CMake Error at qtbase/cmake/QtBuildInformation.cmake:181 (message): Check the configuration messages for an error that has occurred. Call Stack (most recent call first): qtbase/cmake/QtBuildInformation.cmake:21 (qt_configure_print_summary) CMakeLists.txt:111 (qt_print_feature_summary)
The "Toolchain.cmake" file that I used is exactly the same available on the previous link with the correct ${Target-Sysroot} and the "aarch64-linux-gnu-g++-11" Version.
I already checked the directories and everything seems good.
Do you have any ideas?Thanks,
Pedro Martins -
Hi Pedro :-)
It seems, there is a problem on configuration step. Cmake compiles a few tests on that step. To see the real error you should check following file: <buildfolder>/CMakeFiles/CMakeError.log
Could you please share the content of it? You will see error related to following tests inside file: HAVE_EGL/HAVE_GLESv2 or maybe HAVE_openg*** -
Hi Pedro,
I have exactly the same problem. I also followed the instructions on your link and get the same errors at the end. Differences are that I'm using a RPI3B+ with the latest Raspbian 64 Bit Bullseye and checkout out Qt 6.4.1. I don't know if this really makes a big different if the errors are exactly the same.
Did you already find a solution?
My CMakeError.log says this:
Performing C++ SOURCE FILE Test HAVE_EGL failed with the following output: Change Dir: /home/h0rbie/qt_buildenv/qtpi-build/CMakeFiles/CMakeTmp Run Build Command(s):/usr/bin/ninja cmTC_e8779 && [1/2] Building CXX object CMakeFiles/cmTC_e8779.dir/src.cxx.o [2/2] Linking CXX executable cmTC_e8779 FAILED: cmTC_e8779 : && /usr/bin/aarch64-linux-gnu-g++-11 --sysroot=/home/h0rbie/qt_buildenv/rpi-sysroot -I/home/h0rbie/qt_buildenv/rpi-sysroot/usr/include -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed CMakeFiles/cmTC_e8779.dir/src.cxx.o -o cmTC_e8779 -Wl,-rpath,/home/h0rbie/qt_buildenv/rpi-sysroot /home/h0rbie/qt_buildenv/rpi-sysroot/usr/lib/aarch64-linux-gnu/libEGL.so && : /usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: /home/h0rbie/qt_buildenv/rpi-sysroot/lib/aarch64-linux-gnu/libdl.so.2: undefined reference to `_dl_addr@GLIBC_PRIVATE' /usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: /home/h0rbie/qt_buildenv/rpi-sysroot/lib/aarch64-linux-gnu/libdl.so.2: undefined reference to `_dl_vsym@GLIBC_PRIVATE' /usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: /home/h0rbie/qt_buildenv/rpi-sysroot/lib/aarch64-linux-gnu/libdl.so.2: undefined reference to `_dl_sym@GLIBC_PRIVATE' collect2: error: ld returned 1 exit status ninja: build stopped: subcommand failed.
Same goes for GLES2 etc.
BR
Tim -
Hi @Pedro-Martins and everyone,
I'm running into the same issues when I run the configuration command.
I'm using a
RaspberryPi 4 Model B
with the following:PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)" NAME="Raspbian GNU/Linux" VERSION_ID="11" VERSION="11 (bullseye)" VERSION_CODENAME=bullseye
Regarding the Qt build I'm trying to deploy, the branch that I checkout is
6.4.0
. Following the qt-wiki tutorial. Also, myhost
machine has the cross-compileraarch64-linux-gnu-g++-9
andaarch64-linux-gnu-gcc-9
Sorry if it is too much of a trivial question but I want to be sure that I filled correctly the
toolchain.cmake
file that we have to include in the configuration. In the line that you have to specified theTARGET_SYSROOT
likeset(TARGET_SYSROOT /path/to/your/sysroot)
, I included the path created for the sysroot of the Raspi ->rpi-sysroot
, is that correct?I will leave down the first lines of the
CMakeError.log
file in case someone sees something strange. Notice that I replace my home directory with $HOME myself.Thank you in advance.
Performing C++ SOURCE FILE Test TEST_use_lld_linker failed with the following output: Change Dir: $HOME/qtpi-build/CMakeFiles/CMakeScratch/TryCompile-KBJUXn Run Build Command(s):/usr/bin/ninja cmTC_b23ff && [1/2] Building CXX object CMakeFiles/cmTC_b23ff.dir/src.cxx.o [2/2] Linking CXX executable cmTC_b23ff FAILED: cmTC_b23ff : && /usr/bin/aarch64-linux-gnu-g++-9 --sysroot=$HOME/rpi-sysroot -I$HOME/rpi-sysroot/usr/include -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -fuse-ld=lld CMakeFiles/cmTC_b23ff.dir/src.cxx.o -o cmTC_b23ff -Wl,-rpath,$HOME/rpi-sysroot && : collect2: fatal error: cannot find ‘ld’ compilation terminated. ninja: build stopped: subcommand failed. Source file was: int main() { return 0; } Performing C++ SOURCE FILE Test TEST_gdb_index failed with the following output: Change Dir: $HOME/qtpi-build/CMakeFiles/CMakeScratch/TryCompile-aslP9l Run Build Command(s):/usr/bin/ninja cmTC_bdb2a && [1/2] Building CXX object CMakeFiles/cmTC_bdb2a.dir/src.cxx.o [2/2] Linking CXX executable cmTC_bdb2a FAILED: cmTC_bdb2a : && /usr/bin/aarch64-linux-gnu-g++-9 --sysroot=$HOME/rpi-sysroot -I$HOME/rpi-sysroot/usr/include -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,--gdb-index CMakeFiles/cmTC_bdb2a.dir/src.cxx.o -o cmTC_bdb2a -Wl,-rpath,$HOME/rpi-sysroot && : /usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: unrecognised option '--gdb-index' /usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: use the --help option for usage information collect2: error: ld returned 1 exit status ninja: build stopped: subcommand failed. Source file was: int main() { return 0; } Performing C++ SOURCE FILE Test HAVE_reduce_relocations failed with the following output: Change Dir: $HOME/qtpi-build/CMakeFiles/CMakeScratch/TryCompile-Rp1Nto Run Build Command(s):/usr/bin/ninja cmTC_ccad0 && [1/2] Building CXX object CMakeFiles/cmTC_ccad0.dir/src.cxx.o FAILED: CMakeFiles/cmTC_ccad0.dir/src.cxx.o /usr/bin/aarch64-linux-gnu-g++-9 --sysroot=$HOME/rpi-sysroot -DHAVE_reduce_relocations -I$HOME/rpi-sysroot/usr/include -fPIE -std=gnu++17 -o CMakeFiles/cmTC_ccad0.dir/src.cxx.o -c $HOME/qtpi-build/CMakeFiles/CMakeScratch/TryCompile-Rp1Nto/src.cxx $HOME/qtpi-build/CMakeFiles/CMakeScratch/TryCompile-Rp1Nto/src.cxx:2:4: error: #error Symbolic function binding on this architecture may be broken, disabling it (see QTBUG-36129). 2 | # error Symbolic function binding on this architecture may be broken, disabling it (see QTBUG-36129). | ^~~~~ ninja: build stopped: subcommand failed. Source file was: #if !(defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) || defined(__amd64)) || defined(__sun) # error Symbolic function binding on this architecture may be broken, disabling it (see QTBUG-36129). #endif int main(void) { /* BEGIN TEST: */ /* END TEST: */ return 0; } Performing C++ SOURCE FILE Test HAVE_alloca_malloc_h failed with the following output: Change Dir: $HOME/qtpi-build/CMakeFiles/CMakeScratch/TryCompile-jvh1po Run Build Command(s):/usr/bin/ninja cmTC_88f3f && [1/2] Building CXX object CMakeFiles/cmTC_88f3f.dir/src.cxx.o FAILED: CMakeFiles/cmTC_88f3f.dir/src.cxx.o /usr/bin/aarch64-linux-gnu-g++-9 --sysroot=$HOME/rpi-sysroot -DHAVE_alloca_malloc_h -I$HOME/rpi-sysroot/usr/include -fPIE -std=gnu++17 -o CMakeFiles/cmTC_88f3f.dir/src.cxx.o -c $HOME/qtpi-build/CMakeFiles/CMakeScratch/TryCompile-jvh1po/src.cxx $HOME/qtpi-build/CMakeFiles/CMakeScratch/TryCompile-jvh1po/src.cxx: In function ‘int main()’: $HOME/qtpi-build/CMakeFiles/CMakeScratch/TryCompile-jvh1po/src.cxx:6:1: error: ‘alloca’ was not declared in this scope; did you mean ‘valloc’? 6 | alloca(1); | ^~~~~~ | valloc ninja: build stopped: subcommand failed. Source file was: #include <malloc.h> int main(void) { /* BEGIN TEST: */ alloca(1); /* END TEST: */ return 0; } Performing C++ SOURCE FILE Test HAVE_intelcet failed with the following output: Change Dir: $HOME/qtpi-build/CMakeFiles/CMakeScratch/TryCompile-PS6tvl Run Build Command(s):/usr/bin/ninja cmTC_d1be3 && [1/2] Building CXX object CMakeFiles/cmTC_d1be3.dir/src.cxx.o FAILED: CMakeFiles/cmTC_d1be3.dir/src.cxx.o /usr/bin/aarch64-linux-gnu-g++-9 --sysroot=$HOME/rpi-sysroot -DHAVE_intelcet -I$HOME/rpi-sysroot/usr/include -fPIE -std=gnu++17 -o CMakeFiles/cmTC_d1be3.dir/src.cxx.o -c $HOME/qtpi-build/CMakeFiles/CMakeScratch/TryCompile-PS6tvl/src.cxx $HOME/qtpi-build/CMakeFiles/CMakeScratch/TryCompile-PS6tvl/src.cxx:5:4: error: #error Intel CET not available 5 | # error Intel CET not available | ^~~~~ ninja: build stopped: subcommand failed. Source file was: int main(void) { /* BEGIN TEST: */ #if !defined(__CET__) # error Intel CET not available #endif /* END TEST: */ return 0; } etc etc ...
-
Hello @Pedro-Martins and everyone,
I also encountered the same issue. I am using Ubuntu22.04 (Host) with arm-linux-gnueabi-gcc-12.2.0 cross-compiler, my raspberry pi is Raspberry Pi 400 with the same CPU(BCM2711) as Raspberry 4B.
Generally i just followed the tutoria https://wiki.qt.io/Cross-Compile_Qt_6_for_Raspberry_Pi, but i am facing the opengl issue when i configured the raspi-build. The errors generated during the configure step is as follows
My configure command is as below, i am using a 32bit Raspbian, so i choose the MKSPEC "devices/linux-rasp-pi4-v3d-g++" which i am not sure whether is ok.
cmake ../qt5/ -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/qt-raspi -DCMAKE_INSTALL_PREFIX=/usr/local/qt6 -DCMAKE_TOOLCHAIN_FILE=$HOME/qt6-arm-linux-gnueabihf-toolchain.cmake -DQT_QMAKE_TARGET_MKSPEC=devices/linux-rasp-pi4-v3d-g++ -DQT_FEATURE_xcb=ON -DFEATURE_xcb_xlib=ON -DQT_FEATURE_xlib=ON
My toolchain file is as follows:
cmake_minimum_required(VERSION 3.24) include_guard(GLOBAL) set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_PROCESSOR arm) set(TARGET_SYSROOT /usr/local/raspi_sysroot) set(CMAKE_SYSROOT ${TARGET_SYSROOT}) set(ENV{PKG_CONFIG_PATH} $PKG_CONFIG_PATH:/usr/lib/x86_64-linux-gnu/pkgconfig) set(ENV{PKG_CONFIG_LIBDIR} /usr/lib/pkgconfig:/usr/share/pkgconfig/:${TARGET_SYSROOT}/usr/lib/arm-linux-gnueabihf/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 arm-linux-gnueabihf-gcc) set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++) # set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${TARGET_SYSROOT}/usr/include") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -isystem=/usr/include -isystem=/usr/local/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(CMAKE_LIBRARY_PATH "${CMAKE_LIBRARY_PATH}:/usr/local/raspi_sysroot/usr/lib/arm-linux-gnueabihf/") set(XCB_PATH_VARIABLE ${TARGET_SYSROOT}) set(GL_INC_DIR ${TARGET_SYSROOT}/usr/include) set(GL_LIB_DIR ${TARGET_SYSROOT}:${TARGET_SYSROOT}/usr/lib/arm-linux-gnueabihf/:${TARGET_SYSROOT}/usr:${TARGET_SYSROOT}/usr/lib) set(OPENGL_glx_LIBRARY ${XCB_PATH_VARIABLE}/usr/lib/arm-linux-gnueabihf/libGLX.so) set(EGL_INCLUDE_DIR ${GL_INC_DIR}) set(EGL_LIBRARY ${XCB_PATH_VARIABLE}/usr/lib/arm-linux-gnueabihf/libEGL.so) set(OPENGL_egl_LIBRARY ${XCB_PATH_VARIABLE}/usr/lib/arm-linux-gnueabihf/libEGL.so) set(OPENGL_INCLUDE_DIR ${GL_INC_DIR}) set(OPENGL_opengl_LIBRARY ${XCB_PATH_VARIABLE}/usr/lib/arm-linux-gnueabihf/libOpenGL.so) set(OPENGL_glu_LIBRARY ${XCB_PATH_VARIABLE}/usr/lib/arm-linux-gnueabihf/libGLU.so.1) set(GLIB_INCLUDE_DIR ${GL_INC_DIR}) set(GLIB_LIBRARY ${XCB_PATH_VARIABLE}/usr/lib/arm-linux-gnueabihf/libGLESv2.so) set(GLESv2_INCLUDE_DIR ${GL_INC_DIR}) set(GLESv2_LIBRARY ${XCB_PATH_VARIABLE}/usr/lib/arm-linux-gnueabihf/libGLESv2.so) set(gbm_INCLUDE_DIR ${GL_INC_DIR}) set(gbm_LIBRARY ${XCB_PATH_VARIABLE}/usr/lib/arm-linux-gnueabihf/libgbm.so) set(Libdrm_INCLUDE_DIR ${GL_INC_DIR}) set(Libdrm_LIBRARY ${XCB_PATH_VARIABLE}/usr/lib/arm-linux-gnueabihf/libdrm.so) set(XCB_XCB_INCLUDE_DIR ${GL_INC_DIR}) set(XCB_XCB_LIBRARY ${XCB_PATH_VARIABLE}/usr/lib/arm-linux-gnueabihf/libxcb.so)
The CMakeError.log have many compile/link error, i just post one error:
Performing C++ SOURCE FILE Test HAVE_EGL failed with the following output: Change Dir: /home/tangjunyi/build-qt-raspi/CMakeFiles/CMakeScratch/TryCompile-MbQWqV Run Build Command(s):/usr/bin/ninja cmTC_883dd && [1/2] Building CXX object CMakeFiles/cmTC_883dd.dir/src.cxx.o [2/2] Linking CXX executable cmTC_883dd FAILED: cmTC_883dd : && /opt/crosscompile-raspi-gcc/bin/arm-linux-gnueabihf-g++ --sysroot=/usr/local/raspi_sysroot -isystem=/usr/include -isystem=/usr/local/include -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed CMakeFiles/cmTC_883dd.dir/src.cxx.o -o cmTC_883dd -Wl,-rpath,/usr/local/raspi_sysroot /usr/local/raspi_sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so && : /opt/crosscompile-raspi-gcc/lib/gcc/arm-linux-gnueabihf/12.2.0/../../../../arm-linux-gnueabihf/bin/ld: warning: libGLdispatch.so.0, needed by /usr/local/raspi_sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so, not found (try using -rpath or -rpath-link) /opt/crosscompile-raspi-gcc/lib/gcc/arm-linux-gnueabihf/12.2.0/../../../../arm-linux-gnueabihf/bin/ld: /usr/local/raspi_sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so: undefined reference to `__glDispatchGetProcAddress' /opt/crosscompile-raspi-gcc/lib/gcc/arm-linux-gnueabihf/12.2.0/../../../../arm-linux-gnueabihf/bin/ld: /usr/local/raspi_sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so: undefined reference to `__glDispatchFini' /opt/crosscompile-raspi-gcc/lib/gcc/arm-linux-gnueabihf/12.2.0/../../../../arm-linux-gnueabihf/bin/ld: /usr/local/raspi_sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so: undefined reference to `__glDispatchLoseCurrent' /opt/crosscompile-raspi-gcc/lib/gcc/arm-linux-gnueabihf/12.2.0/../../../../arm-linux-gnueabihf/bin/ld: /usr/local/raspi_sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so: undefined reference to `__glDispatchInit' /opt/crosscompile-raspi-gcc/lib/gcc/arm-linux-gnueabihf/12.2.0/../../../../arm-linux-gnueabihf/bin/ld: /usr/local/raspi_sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so: undefined reference to `__glDispatchNewVendorID' /opt/crosscompile-raspi-gcc/lib/gcc/arm-linux-gnueabihf/12.2.0/../../../../arm-linux-gnueabihf/bin/ld: /usr/local/raspi_sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so: undefined reference to `__glDispatchCreateTable' /opt/crosscompile-raspi-gcc/lib/gcc/arm-linux-gnueabihf/12.2.0/../../../../arm-linux-gnueabihf/bin/ld: /usr/local/raspi_sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so: undefined reference to `__glDispatchCheckMultithreaded' /opt/crosscompile-raspi-gcc/lib/gcc/arm-linux-gnueabihf/12.2.0/../../../../arm-linux-gnueabihf/bin/ld: /usr/local/raspi_sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so: undefined reference to `__glDispatchForceUnpatch' /opt/crosscompile-raspi-gcc/lib/gcc/arm-linux-gnueabihf/12.2.0/../../../../arm-linux-gnueabihf/bin/ld: /usr/local/raspi_sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so: undefined reference to `__glDispatchDestroyTable' /opt/crosscompile-raspi-gcc/lib/gcc/arm-linux-gnueabihf/12.2.0/../../../../arm-linux-gnueabihf/bin/ld: /usr/local/raspi_sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so: undefined reference to `__glDispatchReset' /opt/crosscompile-raspi-gcc/lib/gcc/arm-linux-gnueabihf/12.2.0/../../../../arm-linux-gnueabihf/bin/ld: /usr/local/raspi_sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so: undefined reference to `__glDispatchMakeCurrent' /opt/crosscompile-raspi-gcc/lib/gcc/arm-linux-gnueabihf/12.2.0/../../../../arm-linux-gnueabihf/bin/ld: /usr/local/raspi_sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so: undefined reference to `__glDispatchGetABIVersion' /opt/crosscompile-raspi-gcc/lib/gcc/arm-linux-gnueabihf/12.2.0/../../../../arm-linux-gnueabihf/bin/ld: /usr/local/raspi_sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so: undefined reference to `__glDispatchGetCurrentThreadState' collect2: error: ld returned 1 exit status ninja: build stopped: subcommand failed. Source file was: #include <EGL/egl.h> int main(int, char **) { EGLint x = 0; EGLDisplay dpy = 0; EGLContext ctx = 0; eglDestroyContext(dpy, ctx); }
Can anyone give me any hint or advice ?
-
Hi @Pedro-Martins and everyone,
[SOLVED my particular issue]
I found out what was my problem and i have to say that it was a really rookie one.
In my case, I flashed my
Raspberry Pi 4 Model B
using the Raspberry Pi Imager without paying attention to the architecture when I first chose theRaspberry Pi OS
. It turned out that by default, it was downloading the32-bit
image, and theaarch64
cross-compiler mentioned in the Qt6 Cross Compilation is only available for thearmv8
. I realised that because when I tried to retrieved my architecture using$ uname -a
, my output wasarmv7l
which for me it was impossible since theRaspberry Pi 4 Model B
comes with theCortex-A72
.OUTPUT when I change the
COMPILAER FLAG
toarmv7
in the file toolchain.cmake, likeset(QT_COMPILER_FLAGS "-march=armv7")
:cc1plus: note: valid arguments are: armv8-a armv8.1-a armv8.2-a armv8.3-a
armv8.4-a armv8.5-a; did you mean ‘armv8-a’Finally, I flashed my Rasperry Pi with the
64-bit
version of theRapsberry Pi OS
and I started to follow the instructions of the tutorial again. The result was a successful configure of the build.I hope this can help others but it was more a self-mistake than a configuration problem of
openGL
orcmake
. -
Finally, I solved the opengl configure problem as follows, hope it's useful for you guys.
-
Firstly, the configure error says cannnot enable OPENGL, and someone says i should look up the build-qt-raspi/CMakeFiles/CMakeError.log and search the keywords "HAVE_EGL" and "HAVE_GLESv2". And i found HAVE_EGL test failed due to a link error
warning: libGLdispatch.so.0, needed by /usr/local/raspi_sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so, not found (try using -rpath or -rpath-link)
, but libGLdispatch.so.0 is just in the same directory which libEGL.so resides, so i add the compile option in toolchain file-Wl,-rpath-link=/usr/local/raspi_sysroot/usr/lib/arm-linux-gnueabihf/
to force gcc to recursively search libraries depended by the comandline linked library.(my cross-compiler is gcc-12.2 which will not by-default link the library recursively.) -
Secondly, after i repaired the opengl issue, the new error says that XCB::ICCCM, XCB::IMAGE...... can not be found, i realized something is wrong with my search-path config in the toolchain file because those XCB libraries(eg. libxcb-icccm.so, libxcb-image.so, libxcb-xxx.so ) are all in my sysroot. I carefully checked my toolchain file, and i found the environment variable PKG_CONFIG_PATH was set to a directory in Host-PC which is
set(ENV{PKG_CONFIG_PATH} $PKG_CONFIG_PATH:/usr/lib/x86_64-linux-gnu/pkgconfig/)
, but it should point to the sysroot directory, so i corrected the PKG_CONFIG_PATH toset(ENV{PKG_CONFIG_PATH} $PKG_CONFIG_PATH:${CMAKE_SYSROOT}/usr/lib/arm-linux-gnueabihf/pkgconfig)
.
Make fuse that the xcb-xxx.pc file is in your PKG_CONFIG_PATH because the qt cmake scripts will search XCB libraries using PkgConfig.
-
Thirdly, after i fixed the XCB issue, the new error says cannot find the X11::X11 but i already installed all the needed X11 packages listed in the tutotial, so i checked the
FindX11.cmake script which is the cmake install dir and i found it uses the cmake native find_xxx commands to search x11 relevant files. cmake find_xxx command will by-default search the directories in the host, so it can never find the libraries in my sysroot. We can set CMAKE_LIBRARY_PATH variable to let cmake search additional directories:list(APPEND CMAKE_LIBRARY_PATH ${CMAKE_SYSROOT}/usr/lib/arm-linux-gnueabihf)
*Fourthly, after i eliminated all the errors, there is still an warning says md4c_DIR not set, so i installed libmd4c-dev, but the warning still exist, so i checked the FindWrapSystemMd4c.cmake which lies in qt6-sourcecode/qtbase/cmake/, it uses find_package(md4c CONFIG) command to search md4c. The find_package 's CONFIG search mode will first search for a file called md4cConfig.cmake which is actually responsible for the search job of md4c, but the md4cConfig file is also in my sysroot, So i set the CMAKE_PREFIX_PATH
list(APPEND CMAKE_PREFIX_PATH "/usr/lib/arm-linux-gnueabihf/cmake")
to tell cmake to search my sysroot for the cmake config file.
Make sure that the cmake config file is in your CMAKE_PREFIX_PATH.
*At last, i encountered a compile error when i started building for the Raspberry Pi 400.
error: no matching function for call to ‘min(float,std::enable_if()
which points to qt6-sourcecode/qtquick3d/src/quick3dparticles/qquick3dparticleemitter.cpp
Maybe my cross-compiler's gcc version(gcc-12.2) is a little high, so it cannot match the std::min to std::min<float>, so i just simply added the explicit instantiation std::min<float> as follows:
-
Ending, after i finished the build and install. I started to cross-compile the analogclock example, but during linking, an error occurs saying
/opt/crosscompile-raspi-gcc/lib/gcc/arm-linux-gnueabihf/12.2.0/../../../../arm-linux-gnueabihf/bin/ld: warning: libQt6DBus.so.6, needed by /home/tangjunyi/qt-raspi/lib/libQt6Gui.so.6.4.0, not found (try using -rpath or -rpath-link)
. The reason is as same as the first issue during configure step. I just add the compile option-Wl,-rpath-link=$HOME/qt-raspi/lib
-
appendix
my toolchain file is as follows:
cmake_minimum_required(VERSION 3.24) include_guard(GLOBAL) set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_PROCESSOR arm) set(CMAKE_SYSROOT /usr/local/raspi_sysroot) set(ENV{PKG_CONFIG_PATH} $PKG_CONFIG_PATH:${CMAKE_SYSROOT}/usr/lib/arm-linux-gnueabihf/pkgconfig) set(ENV{PKG_CONFIG_LIBDIR} ${CMAKE_SYSROOT}/usr/share/pkgconfig:${CMAKE_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 arm-linux-gnueabihf-gcc) set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++) # set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_SYSROOT}/usr/include") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -isystem=/usr/include -isystem=/usr/local/include -isystem=/usr/include/arm-linux-gnueabihf") 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,-rpath-link=/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link=$HOME/qt-raspi/lib") 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 ${CMAKE_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() list(APPEND CMAKE_LIBRARY_PATH ${CMAKE_SYSROOT}/usr/lib/arm-linux-gnueabihf) list(APPEND CMAKE_PREFIX_PATH "/usr/lib/arm-linux-gnueabihf/cmake")
-
-
-