Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Cross compile Qt6 on raspberry pi
Forum Updated to NodeBB v4.3 + New Features

Cross compile Qt6 on raspberry pi

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
4 Posts 2 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Fangry
    wrote on 7 Dec 2022, 14:56 last edited by Fangry 12 Jul 2022, 14:58
    #1

    Hi,

    I tried to cross compile Qt v6.1.0 for my raspberry pi 4 vith 64bit raspbian on it.
    I follow this tutorial Cross-Compile Qt 6 for Raspberry Pi

    I am on a virtual box in a linux ubuntu jellyfish 22.0.4.

    I compiled only qt base for the beginning and the firt part of the operation (host compilation) was successfull

    I am stuck to the cross compiling configure. When I run cmake a get errors

    CMake Error at qtbase/src/corelib/Qt6CoreMacros.cmake:2061 (add_library):
      Target "Gui" links to target "GLESv2::GLESv2" but the target was not found.
      Perhaps a find_package() call is missing for an IMPORTED target, or an
      ALIAS target is missing?
    Call Stack (most recent call first):
      qtbase/cmake/QtModuleHelpers.cmake:130 (_qt_internal_add_library)
      qtbase/src/gui/CMakeLists.txt:53 (qt_internal_add_module)
    
    

    as I understand it seems that cmake cannot find GLESv2 library, but think my sysroot is correctly set and I can find the file libGLESv2.so in sysroot/usr/lib nd also in /opt/vc.
    Although the sim links are correctly set

    I tried to find an answer on other forums but i did not found any post with a similar problem to mine.
    I used this command

    ../qt5/configure -release -opengl es2 -nomake examples -nomake tests -qt-host-path $HOME/qt-host -extprefix $HOME/qt-raspi -prefix /usr/local/qt6 -device linux-rasp-pi4-aarch64 -device-option CROSS_COMPILE=aarch64-linux-gnu- -- -DCMAKE_TOOLCHAIN_FILE=$HOME/toolchain.cmake -DQT_FEATURE_xcb=ON -DFEATURE_xcb_xlib=ON -DQT_FEATURE_xlib=ON -DQT_FEATURE_opengles2=ON
    
    

    This is my toolchain file

    cmake_minimum_required(VERSION 3.18)
    include_guard(GLOBAL)
    
    set(CMAKE_SYSTEM_NAME Linux)
    set(CMAKE_SYSTEM_PROCESSOR arm)
    
    set(TARGET_SYSROOT /home/fangry/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 /usr/bin/aarch64-linux-gnu-gcc-11)
    set(CMAKE_CXX_COMPILER /usr/bin/aarch64-linux-gnu-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")
    
    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)
    

    Could you help me to understand what happened and help me to achieve this cross compile.

    Thank you

    J 1 Reply Last reply 8 Dec 2022, 06:50
    0
    • F Fangry
      7 Dec 2022, 14:56

      Hi,

      I tried to cross compile Qt v6.1.0 for my raspberry pi 4 vith 64bit raspbian on it.
      I follow this tutorial Cross-Compile Qt 6 for Raspberry Pi

      I am on a virtual box in a linux ubuntu jellyfish 22.0.4.

      I compiled only qt base for the beginning and the firt part of the operation (host compilation) was successfull

      I am stuck to the cross compiling configure. When I run cmake a get errors

      CMake Error at qtbase/src/corelib/Qt6CoreMacros.cmake:2061 (add_library):
        Target "Gui" links to target "GLESv2::GLESv2" but the target was not found.
        Perhaps a find_package() call is missing for an IMPORTED target, or an
        ALIAS target is missing?
      Call Stack (most recent call first):
        qtbase/cmake/QtModuleHelpers.cmake:130 (_qt_internal_add_library)
        qtbase/src/gui/CMakeLists.txt:53 (qt_internal_add_module)
      
      

      as I understand it seems that cmake cannot find GLESv2 library, but think my sysroot is correctly set and I can find the file libGLESv2.so in sysroot/usr/lib nd also in /opt/vc.
      Although the sim links are correctly set

      I tried to find an answer on other forums but i did not found any post with a similar problem to mine.
      I used this command

      ../qt5/configure -release -opengl es2 -nomake examples -nomake tests -qt-host-path $HOME/qt-host -extprefix $HOME/qt-raspi -prefix /usr/local/qt6 -device linux-rasp-pi4-aarch64 -device-option CROSS_COMPILE=aarch64-linux-gnu- -- -DCMAKE_TOOLCHAIN_FILE=$HOME/toolchain.cmake -DQT_FEATURE_xcb=ON -DFEATURE_xcb_xlib=ON -DQT_FEATURE_xlib=ON -DQT_FEATURE_opengles2=ON
      
      

      This is my toolchain file

      cmake_minimum_required(VERSION 3.18)
      include_guard(GLOBAL)
      
      set(CMAKE_SYSTEM_NAME Linux)
      set(CMAKE_SYSTEM_PROCESSOR arm)
      
      set(TARGET_SYSROOT /home/fangry/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 /usr/bin/aarch64-linux-gnu-gcc-11)
      set(CMAKE_CXX_COMPILER /usr/bin/aarch64-linux-gnu-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")
      
      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)
      

      Could you help me to understand what happened and help me to achieve this cross compile.

      Thank you

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 8 Dec 2022, 06:50 last edited by
      #2

      @Fangry said in Cross compile Qt6 on raspberry pi:

      and I can find the file libGLESv2.so in sysroot/usr/lib

      Can you also find its header files? For building library itself is not enough.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Fangry
        wrote on 8 Dec 2022, 07:41 last edited by
        #3

        Hi,

        @jsulm said in Cross compile Qt6 on raspberry pi:

        @Fangry said in Cross compile Qt6 on raspberry pi:

        and I can find the file libGLESv2.so in sysroot/usr/lib

        Can you also find its header files? For building library itself is not enough.

        I will check that immediately.

        I also make more search and I find an start of an answer by reading this post

        When I check the result of the tests have EGL and have GLES I found that errors occurs with the link with glibc
        more precisely i have an undifined reference to function@glibc_private

        1 Reply Last reply
        0
        • F Offline
          F Offline
          Fangry
          wrote on 8 Dec 2022, 09:39 last edited by Fangry 12 Aug 2022, 10:32
          #4

          @Fangry said in Cross compile Qt6 on raspberry pi:

          Hi,

          @jsulm said in Cross compile Qt6 on raspberry pi:

          @Fangry said in Cross compile Qt6 on raspberry pi:

          and I can find the file libGLESv2.so in sysroot/usr/lib

          Can you also find its header files? For building library itself is not enough.

          I will check that immediately.

          I also make more search and I find an start of an answer by reading this post

          When I check the result of the tests have EGL and have GLES I found that errors occurs with the link with glibc
          more precisely i have an undifined reference to function@glibc_private

          So I check my include sysroot and I have the include files correctly set.

          I Check again the cmake error log and i found some error before have EGL.
          More precisely from building files with ld.

          Performing C++ SOURCE FILE Test TEST_use_lld_linker failed with the following output:
          Change Dir: /home/fangry/qtpi-build/CMakeFiles/CMakeTmp
          
          Run Build Command(s):/usr/bin/ninja cmTC_a7ba6 && [1/2] Building CXX object CMakeFiles/cmTC_a7ba6.dir/src.cxx.o
          [2/2] Linking CXX executable cmTC_a7ba6
          FAILED: cmTC_a7ba6 
          : && /usr/bin/aarch64-linux-gnu-g++-11 --sysroot=/home/fangry/rpi-sysroot -I/home/fangry/rpi-sysroot/usr/include -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed    -fuse-ld=lld CMakeFiles/cmTC_a7ba6.dir/src.cxx.o -o cmTC_a7ba6  -Wl,-rpath,/home/fangry/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/fangry/qtpi-build/CMakeFiles/CMakeTmp
          
          Run Build Command(s):/usr/bin/ninja cmTC_88e8c && [1/2] Building CXX object CMakeFiles/cmTC_88e8c.dir/src.cxx.o
          [2/2] Linking CXX executable cmTC_88e8c
          FAILED: cmTC_88e8c 
          : && /usr/bin/aarch64-linux-gnu-g++-11 --sysroot=/home/fangry/rpi-sysroot -I/home/fangry/rpi-sysroot/usr/include -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed    -Wl,--gdb-index CMakeFiles/cmTC_88e8c.dir/src.cxx.o -o cmTC_88e8c  -Wl,-rpath,/home/fangry/rpi-sysroot && :
          /usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: unrecognized option '--gdb-index'
          /usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: use the --help option for usage information
          collect2: error: ld returned 1 exit status
          ninja: build stopped: subcommand failed.
          
          

          It seems that aarch64 gnu ld in version 11 does not take --gdb-index in option. how can i remove it frome build ?

          1 Reply Last reply
          0

          1/4

          7 Dec 2022, 14:56

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved