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 compilation qt6 for raspberry pi build failure, can't find .so files
QtWS25 Last Chance

Cross compilation qt6 for raspberry pi build failure, can't find .so files

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
cross compileqt6armv7raspberry pilinux
3 Posts 2 Posters 1.9k Views
  • 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.
  • M Offline
    M Offline
    matio
    wrote on 15 May 2022, 16:24 last edited by
    #1

    Hello,

    I try to build Qt 6.1.3 for Raspberry Pi 3 with my x64 PC.

    I had no big issue while configuring for cross compilation. I also succeed to build Qt for the host following the page:

    https://wiki.qt.io/Building_Qt_6_from_Git

    I encoutered some issue at build. It seems that at build, the compiler/linker doesn't find the ".so" files he just generated.

    The output message is :

    $MY_QT_TEST_DIR_PATH/toolchain/qt-cross/qtbase/libexec/uic: error while loading shared libraries: libQt6Core.so.6: cannot open shared object file: No such file or directory
    

    I followed the informations in this page:

    https://doc-snapshots.qt.io/qt6-dev/configure-linux-device.html

    my work dir is set like this:

    $MY_QT_TEST_DIR_PATH/qt6-build: build dir for host's Qt
    $MY_QT_TEST_DIR_PATH/qt-host: install dir for host's Qt
    $MY_QT_TEST_DIR_PATH/rpi-sdk/sysroot: sysroot creatred with rsync from rpi
    $MY_QT_TEST_DIR_PATH/qt-cross: build dir for target's Qt
    $MY_QT_TEST_DIR_PATH/qt-sources: Qt sources configured
    

    My toolchain.cmake file:

    set(TARGET_NAME "arm-rpi")
    	
    # project template options
    set(CMAKE_SYSTEM_NAME Linux)
    set(CMAKE_SYSTEM_PROCESSOR armv)
    #set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
    
    
    # crosschain compiler
    set(CROSSCHAIN_SYSROOT "$MY_QT_TEST_DIR_PATH/toolchain/rpi-sdk/sysroot")
    set(CROSSCHAIN_PATH "/usr/bin")      # not sure
    set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
    set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)
    set(CMAKE_SYSROOT ${SYSROOTS})
    	
    set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} --sysroot=\"${CROSSCHAIN_SYSROOT}\"")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --sysroot=\"${CROSSCHAIN_SYSROOT}\"")
    
    set(LD_LIBRARY_PATH "$MY_QT_TEST_DIR_PATH/toolchain/qt-cross/qtbase/lib/") # just tried this because of current problem but doesn't changed anything, set even if out of this file as env variable
    
    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")
    
    message("CMAKE_C_FLAGS=${CMAKE_C_FLAGS}")
    message("CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}")	
    
    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)
    
    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()
    

    My configure command:

    $MY_QT_TEST_DIR_PATH/toolchain/qt-sources/configure -release -opengl es2 -nomake examples -nomake tests -qt-host-path $MY_QT_TEST_DIR_PATH/toolchain/qt-host -extprefix $MY_QT_TEST_DIR_PATH/toolchain/qt-cross -prefix $MY_QT_TEST_DIR_PATH/toolchain/rpi-sdk/toolchain -DCMAKE_TOOLCHAIN_FILE=$MY_QT_TEST_DIR_PATH/toolchain/qt-cross/toolchain.cmake
    

    I have some doubts about things:

    For the toolchain, for Qt5 I used a cross compilation toolchain I found here:

    https://github.com/raspberrypi/tools

    But it seems to be obsolete. So I followed the instructions by installing "gcc-arm-linux-gnueabihf" and "g++-arm-linux-gnueabihf" with apt. So I presume that I should consider that the toolchain is installed in "/usr/bin" since "gcc-arm-linux-gnueabihf" is installed there? So I should set "CROSSCHAIN_PATH" as "/usr/bin"? I'd prefer downloading an up to date toolchain like I did for qt5 but I haven't found one. Does this exists?

    Another point: I suppose that the "so" files have to be the one generated by the cross compiler in "$MY_QT_TEST_DIR_PATH/qt-cross/qtbase" ?

    I'm not an expert on build tools, I try to understand but I think some knowledges are missing to me!

    Can you help me? Thank you for any help!

    1 Reply Last reply
    0
    • T Offline
      T Offline
      Tatiana Borisova
      wrote on 14 Jun 2022, 16:27 last edited by
      #2

      Hi matio,

      I see I am a little bit late. You asked your question almost month ago, but..

      For cross-compiling you need:

      1. Build Qt 6.1.3 for HOST and install it (run "cmake install . " )
      2. create sysroot
      3. create toolchain.cmake file
      4. configure
      5. cmake build .
      6. cmake install .

      I cross-built for Rasp Pi device recently and maybe following configure command can be helpful for you cross-building:

      cmake ../qt5/ -GNinja -DCMAKE_BUILD_TYPE=Release -DINPUT_opengl=es2 -DQT_BUILD_EXAMPLES=OFF -DQT_BUILD_TESTS=OFF -DQT_HOST_PATH=$MY_QT_TEST_DIR_PATH/toolchain/qt-cross -DCMAKE_INSTALL_PREFIX=$MY_QT_TEST_DIR_PATH/toolchain/rpi-sdk/toolchain -DCMAKE_TOOLCHAIN_FILE=$MY_QT_TEST_DIR_PATH/toolchain/qt-cross/toolchain.cmake  -DQT_FEATURE_brotli=OFF -DQT_FEATURE_libudev=OFF  -DQT_QMAKE_TARGET_MKSPEC=devices/linux-rasp-pi3-g++
      

      Also regarding CROSSCHAIN_PATH - it is optional.
      You can install compilers on sustem and do directly following inside toolchain file:

      set(CMAKE_C_COMPILER /usr/bin/arm-linux-gnueabihf-gcc)
      set(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabihf-g++)
      

      I think you can exchange:

      set(TARGET_NAME "arm-rpi")
      
      # project template options
      set(CMAKE_SYSTEM_NAME Linux)
      set(CMAKE_SYSTEM_PROCESSOR armv)
      #set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
      
      # crosschain compiler
      set(CROSSCHAIN_SYSROOT "$MY_QT_TEST_DIR_PATH/toolchain/rpi-sdk/sysroot")
      set(CROSSCHAIN_PATH "/usr/bin")      # not sure
      set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
      set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)
      set(CMAKE_SYSROOT ${SYSROOTS})
      	
      set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} --sysroot=\"${CROSSCHAIN_SYSROOT}\"")
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --sysroot=\"${CROSSCHAIN_SYSROOT}\"")
      

      With following:

      cmake_minimum_required(VERSION 3.18)
      include_guard(GLOBAL)
      
      set(CMAKE_SYSTEM_NAME Linux)
      set(CMAKE_SYSTEM_PROCESSOR arm)
      
      set(TARGET_SYSROOT "$MY_QT_TEST_DIR_PATH/toolchain/rpi-sdk/sysroot") 
      set(CMAKE_SYSROOT ${TARGET_SYSROOT})
      
      set(ENV{PKG_CONFIG_PATH} "")
      set(ENV{PKG_CONFIG_LIBDIR} ${CMAKE_SYSROOT}/usr/lib/pkgconfig:${CMAKE_SYSROOT}/usr/share/pkgconfig:${CMAKE_SYSROOT}/${TARGET_SYSROOT}/pkgconfig)
      set(ENV{PKG_CONFIG_SYSROOT_DIR} ${CMAKE_SYSROOT})
      
      set(CMAKE_C_COMPILER /usr/bin/arm-linux-gnueabihf-gcc)
      set(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabihf-g++)
      

      About the "so" files have to be the one generated by the cross compiler:
      Please, if problem is still valid share full compilation error log.

      NOTE: Also speaking about Raspberry Pi 3, are you sure that you HW is march=armv7-a based?*
      (you can check like pi@raspberrypi:~ $ uname -a)

      I see from qt configs for Raspbery pi3: QMAKE_CFLAGS = -march=armv8-a -mtune=cortex-a53 -mfpu=crypto-neon-fp-armv8

      In case it is arm8 you should use another compilers (for example aarch64-linux-gnu-gcc/aarch64-linux-gnu-g++) + flags

      set(QT_COMPILER_FLAGS "-march=armv8-a " .....)
      
      1 Reply Last reply
      2
      • T Offline
        T Offline
        Tatiana Borisova
        wrote on 23 Jun 2022, 07:33 last edited by
        #3

        Also there is a new instruction for Rasp + Qt6:
        https://wiki.qt.io/Cross-Compile_Qt_6_for_Raspberry_Pi

        1 Reply Last reply
        2

        • Login

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