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. QT6 Cross Compilation for Beaglebone Black
Qt 6.11 is out! See what's new in the release blog

QT6 Cross Compilation for Beaglebone Black

Scheduled Pinned Locked Moved Solved Mobile and Embedded
8 Posts 2 Posters 2.7k 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.
  • T Offline
    T Offline
    timroberts
    wrote on last edited by
    #1

    Hello,

    I'm attempting to cross compile Qt6 for use on a Beaglebone black and I'm running into difficulties. The configure that I'm using is:

    ../qt6/configure -release -no-opengl -device linux-rasp-pi2-g++ -device-option CROSS_COMPILE=$HOME/opt/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf- -sysroot $HOME/opt/sysroot -prefix $HOME/Qt6ForBBB
    

    I then use

    cmake --build . --parallel 4
    

    to build and

    cmake --install
    

    to install. The build and install instructions are as per the documentation. The configure command is me attempting to muddle my way through on my own since I can't find anything for how to do this on a Beaglebone black.

    When I open Qt Creator, I'm able to pick up the Qt installation, but I'm unable to use it to make a Beaglebone black kit. There is an error for the Beaglebone black kit that I've created where it is expecting an armhf 32 bit executable but Qt is producing an x86_64 executable. I suspect the issue is somewhere in my configuration/compilation process, but I don't know where I'm going wrong or how to fix it.

    Image of my error is below

    (Error.jpg

    Can somebody please set me straight on how to do this?

    Thanks!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What you did looks fine.
      Did you check that the built libraries are indeed for arm ? Just to rule out that it's a build issue.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      T 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        What you did looks fine.
        Did you check that the built libraries are indeed for arm ? Just to rule out that it's a build issue.

        T Offline
        T Offline
        timroberts
        wrote on last edited by
        #3

        @SGaist

        Thanks for replying. How would I go about doing that?

        SGaistS 1 Reply Last reply
        0
        • T timroberts

          @SGaist

          Thanks for replying. How would I go about doing that?

          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @timroberts file path/to/cross-compiled-Qt/lib/libQtCore6.so. Adjust the library name as needed.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          T 1 Reply Last reply
          1
          • SGaistS SGaist

            @timroberts file path/to/cross-compiled-Qt/lib/libQtCore6.so. Adjust the library name as needed.

            T Offline
            T Offline
            timroberts
            wrote on last edited by
            #5

            @SGaist interesting.

            libQt6Core.so.6.5.4: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=6014e9e2798e0bc915081673b539dcadb1540d9a, for GNU/Linux 3.17.0, not stripped
            

            So it's been built for an x86-64 bit system. How do I get it to build for the CORRECT architecture? I thought the configure was supposed to handle that.

            SGaistS 1 Reply Last reply
            0
            • T timroberts

              @SGaist interesting.

              libQt6Core.so.6.5.4: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=6014e9e2798e0bc915081673b539dcadb1540d9a, for GNU/Linux 3.17.0, not stripped
              

              So it's been built for an x86-64 bit system. How do I get it to build for the CORRECT architecture? I thought the configure was supposed to handle that.

              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @timroberts looks like I missed something.

              I just went through the wiki page for cross-compiling Qt for the RPi and it seems you are missing the toolchain file.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              T 1 Reply Last reply
              1
              • SGaistS SGaist

                @timroberts looks like I missed something.

                I just went through the wiki page for cross-compiling Qt for the RPi and it seems you are missing the toolchain file.

                T Offline
                T Offline
                timroberts
                wrote on last edited by
                #7

                @SGaist Thank you for the helpful link. I'm working through translating the cmake file to work on my system, but I am running into something I need some help for.

                I've managed to put together a toolchain.cmake file here:

                cmake_minimum_required(VERSION 3.18)
                include_guard(GLOBAL)
                
                set(CMAKE_SYSTEM_NAME Linux)
                set(CMAKE_SYSTEM_PROCESSOR arm)
                
                set(TARGET_SYSROOT /home/debian/opt/sysroot)
                set(CMAKE_SYSROOT ${TARGET_SYSROOT})
                set(CROSS_COMPILER /usr/bin)
                0	
                set(CMAKE_SYSROOT ${TARGET_SYSROOT})
                
                set(ENV{PKG_CONFIG_PATH} $PKG_CONFIG_PATH:/usr/lib/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})
                
                set(CMAKE_C_COMPILER ${CROSS_COMPILER}/arm-linux-gnueabihf-gcc)
                set(CMAKE_CXX_COMPILER ${CROSS_COMPILER}/arm-linux-gnueabihf-g++)
                
                set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${TARGET_SYSROOT}/usr/include")
                set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}")
                
                set(QT_COMPILER_FLAGS "-march=armv7-a -mfpu=neon -mfloat-abi=hard")
                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_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()
                

                However when I run it, I'm getting some unexpected errors. The errors are:

                CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
                CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
                CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
                CMake Error: CMAKE_ASM_COMPILER not set, after EnableLanguage
                

                This is odd as I have ninja-build installed on both my host as well as it is in sysroot/usr/bin. What can I do to get cmake to recognize my ninja install?

                T 1 Reply Last reply
                0
                • T timroberts

                  @SGaist Thank you for the helpful link. I'm working through translating the cmake file to work on my system, but I am running into something I need some help for.

                  I've managed to put together a toolchain.cmake file here:

                  cmake_minimum_required(VERSION 3.18)
                  include_guard(GLOBAL)
                  
                  set(CMAKE_SYSTEM_NAME Linux)
                  set(CMAKE_SYSTEM_PROCESSOR arm)
                  
                  set(TARGET_SYSROOT /home/debian/opt/sysroot)
                  set(CMAKE_SYSROOT ${TARGET_SYSROOT})
                  set(CROSS_COMPILER /usr/bin)
                  0	
                  set(CMAKE_SYSROOT ${TARGET_SYSROOT})
                  
                  set(ENV{PKG_CONFIG_PATH} $PKG_CONFIG_PATH:/usr/lib/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})
                  
                  set(CMAKE_C_COMPILER ${CROSS_COMPILER}/arm-linux-gnueabihf-gcc)
                  set(CMAKE_CXX_COMPILER ${CROSS_COMPILER}/arm-linux-gnueabihf-g++)
                  
                  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${TARGET_SYSROOT}/usr/include")
                  set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}")
                  
                  set(QT_COMPILER_FLAGS "-march=armv7-a -mfpu=neon -mfloat-abi=hard")
                  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_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()
                  

                  However when I run it, I'm getting some unexpected errors. The errors are:

                  CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
                  CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
                  CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
                  CMake Error: CMAKE_ASM_COMPILER not set, after EnableLanguage
                  

                  This is odd as I have ninja-build installed on both my host as well as it is in sysroot/usr/bin. What can I do to get cmake to recognize my ninja install?

                  T Offline
                  T Offline
                  timroberts
                  wrote on last edited by
                  #8

                  @timroberts Disregard last message, I found an extra "0" in the toolchain file. I've successfully built and installed a 32bit arm Qt install. For anybody interested, my updated toolchain.cmake is here:

                  cmake_minimum_required(VERSION 3.18)
                  include_guard(GLOBAL)
                  
                  set(CMAKE_SYSTEM_NAME Linux)
                  set(CMAKE_SYSTEM_PROCESSOR arm)
                  
                  set(TARGET_SYSROOT /home/debian/opt/sysroot)
                  set(CMAKE_SYSROOT ${TARGET_SYSROOT})
                  set(CROSS_COMPILER /usr/bin)
                  	
                  set(CMAKE_SYSROOT ${TARGET_SYSROOT})
                  
                  set(ENV{PKG_CONFIG_PATH} $PKG_CONFIG_PATH:/usr/lib/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})
                  
                  set(CMAKE_C_COMPILER ${CROSS_COMPILER}/arm-linux-gnueabihf-gcc)
                  set(CMAKE_CXX_COMPILER ${CROSS_COMPILER}/arm-linux-gnueabihf-g++)
                  
                  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${TARGET_SYSROOT}/usr/include")
                  set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}")
                  
                  set(QT_COMPILER_FLAGS "-march=armv7-a -mfpu=neon -mfloat-abi=hard")
                  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_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()
                  

                  It may be worthwhile to reference my configure command at this point is:

                  ../opt/qt6/configure -release -no-opengl -nomake examples -nomake tests -qt-host-path $HOME/qt-host -extprefix $HOME/qt6-bbb -prefix /usr/local/qt6 -device linux-beagleboard-g++ -device-option CROSS_COMPILE=arm-linux-gnueabihf- -- -DCMAKE_TOOLCHAIN_FILE=$HOME/toolchain.cmake
                  

                  Thanks so much for your help @SGaist ! This looks promising!

                  1 Reply Last reply
                  2
                  • T timroberts has marked this topic as solved on

                  • Login

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