cross-compile Qt 6 for BBB. Compiled example returns errors:
./gui_analogclock: /lib/arm-linux-gnueabihf/libc.so.6: version GLIBC_2.34' not found (required by ./gui_analogclock) ./gui_analogclock: /lib/arm-linux-gnueabihf/libm.so.6: version
GLIBC_2.35’ not found (required by /usr/local/qt6/lib/libQt6Gui.so.6)
Here’s my procedure:
create cross-compile of Qt for BeagleBone Black
ref: QT6 Cross Compilation for Beaglebone Black | Qt Forum
ref: Cross-Compile Qt 6 for Raspberry Pi - Qt Wiki
host is Ubuntu 22.04.02 running on virtual box 7.0
on host
cd ~
mkdir bbb-sysroot bbb-sysroot/usr bbb-sysroot/opt
mkdir qt-host qt-bbb qt-hostbuild qtbbb-build
on beaglebone black, the target
install the package dependencies
sudo apt-get install libboost-all-dev libudev-dev libinput-dev libts-dev libmtdev-dev libjpeg-dev libfontconfig1-dev libssl-dev libdbus-1-dev libglib2.0-dev libxkbcommon-dev libegl1-mesa-dev libgbm-dev libgles2-mesa-dev mesa-common-dev libasound2-dev libpulse-dev gstreamer1.0-omx libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-alsa libvpx-dev libsrtp2-dev libsnappy-dev libnss3-dev “^libxcb.*” flex bison libxslt-dev ruby gperf libbz2-dev libcups2-dev libatkmm-1.6-dev libxi6 libxcomposite1 libfreetype6-dev libicu-dev libsqlite3-dev libxslt1-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libx11-dev freetds-dev libpq-dev libiodbc2-dev firebird-dev libgst-dev libxext-dev libxcb1 libxcb1-dev libx11-xcb1 libx11-xcb-dev libxcb-keysyms1 libxcb-keysyms1-dev libxcb-image0 libxcb-image0-dev libxcb-shm0 libxcb-shm0-dev libxcb-icccm4 libxcb-icccm4-dev libxcb-sync1 libxcb-sync-dev libxcb-render-util0 libxcb-render-util0-dev libxcb-xfixes0-dev libxrender-dev libxcb-shape0-dev libxcb-randr0-dev libxcb-glx0-dev libxi-dev libdrm-dev libxcb-xinerama0 libxcb-xinerama0-dev libatspi2.0-dev libxcursor-dev libxcomposite-dev libxdamage-dev libxss-dev libxtst-dev libpci-dev libcap-dev libxrandr-dev libdirectfb-dev libaudio-dev libxkbcommon-x11-dev
sudo mkdir /usr/local/qt6
on host
install dependencies
sudo apt-get install make cmake build-essential libclang-dev clang ninja-build gcc git bison python3 gperf pkg-config libfontconfig1-dev libfreetype6-dev libx11-dev libx11-xcb-dev libxext-dev libxfixes-dev libxi-dev libxrender-dev libxcb1-dev libxcb-glx0-dev libxcb-keysyms1-dev libxcb-image0-dev libxcb-shm0-dev libxcb-icccm4-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb-shape0-dev libxcb-randr0-dev libxcb-render-util0-dev libxcb-util-dev libxcb-xinerama0-dev libxcb-xkb-dev libxkbcommon-dev libxkbcommon-x11-dev libatspi2.0-dev libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev
install cross-compiler
sudo apt-get install crossbuild-essential-armhf
get linaro toolchain for linaro.org
gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf
extract
add path to bin folder to bottom ./bashrc file
PATH=$PATH:/home/ram/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin
sudo apt install rsync
rsync -avzS --rsync-path=“rsync” --delete debian@192.168.1.23:/lib/* bbb-sysroot/lib
rsync -avzS --rsync-path=“rsync” --delete debian@192.168.1.23:/usr/include/* bbb-sysroot/usr/include
rsync -avzS --rsync-path=“rsync” --delete debian@192.168.1.23:/usr/lib/* bbb-sysroot/usr/lib
sudo apt install symlinks
cd ~
symlinks -rc bbb-sysroot
building Qt6
first build for host
cd ~
git clone "https://codereview.qt-project.org/qt/qt5
cd qt5
git checkout 6.4.0
perl init-repository -f --module-subset=default,-qtwebengine
cd …
mkdir $HOME/qt-hostbuild
cd $HOME/qt-hostbuild
cmake …/qt5/ -GNinja -DCMAKE-BUILD_TYPE=Release -DQT_BUILD_EXAMPLES=OFF -DQT_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=$HOME/qt-host
cmake --build . --parallel
cmake --install .
build Qt 6 for BBB
cd ~
nano toolchain.cmake
reference Cross-Compile Qt 6 for Raspberry Pi - Qt Wiki
cmake_minimum_required(VERSION 3.18)
include_guard(GLOBAL)
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
#set(TARGET_SYSROOT /path/to/your/sysroot)
set(TARGET_SYSROOT $HOME/bbb_sysroot)
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})
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-9)
set(CMAKE_C_COMPILER /usr/bin/arm-linux-gnueabihf-gcc)
#set(CMAKE_CXX_COMPILER /usr/bin/aarch64-linux-gnu-g+±9)
set(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabihf-g++)
set(CMAKE_C_FLAGS “${CMAKE_C_FLAGS} -I${TARGET_SYSROOT}/usr/include”)
#set(CMAKE_C_FLAGS “${CMAKE_C_FLAGS} -I${TARGET_SYSROOT}/usr/include -static”)
set(CMAKE_CXX_FLAGS “${CMAKE_C_FLAGS}”)
set(QT_COMPILER_FLAGS “-march=armv7-a -mfpu=neon -mfloat-abi=hard”)
#set(QT_COMPILER_FLAGS “-march=armv7-a -mfpu=neon -mfloat-abi=hard -static”)
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(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)
cd ~qtbbb-build
…/qt5/configure -release -no-opengl -nomake examples -nomake tests -qt-host-path $HOME/qt-host -extprefix $HOME/qt-bbb -prefix /usr/local/qt6 -device linux-beagleboard-g++ -device-option CROSS-COMPILE=arm-linux-gnueabihf- – -DCMAKE_TOOLCHAIN_FILE=$HOME/toolchain.cmake
cmake --build . --parallel
cmake --install .
Qt will be installed at ~/qt-bbb on Host and at /usr/local/qt6 on BBB
so to copy from ~/qt-bbb(on host) to /usr/local/qt6 on BBB
first copy to ~/qt6 on BBB
cd ~/qt-bbb
scp -r * debian@192.168.1.23:/home/debian/qt6
then on BBB: mv qt6 /usr/local/
set environment variables (eventually add to ./bashrc)
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/qt6/lib/
export DISPLAY=:0
Compile and run Qt project
cd ~/qt5/qtbase/examples/gui/analogclock/
~/qt-bbb/bin/qt-cmake CMakeLists.txt
cmake --build . --parallel
cmake --install .
scp -r gui_analogclock debain@192.168.1.xx:/home/debian
./gui_analogclock
errors:
debian@BeagleBone:~$ ./gui_analogclock
./gui_analogclock: /lib/arm-linux-gnueabihf/libc.so.6: version `GLIBC_2.34’ not found (required by ./gui_analogclock)
./gui_analogclock: /lib/arm-linux-gnueabihf/libm.so.6: version `GLIBC_2.35’ not found (required by /usr/local/qt6/lib/libQt6Gui.so.6)
./gui_analogclock: /usr/lib/arm-linux-gnueabihf/libstdc++.so.6: version `GLIBCXX_3.4.29’ not found (required by /usr/local/qt6/lib/libQt6Gui.so.6)
./gui_analogclock: /lib/arm-linux-gnueabihf/libc.so.6: version `GLIBC_2.33’ not found (required by /usr/local/qt6/lib/libQt6Gui.so.6)
./gui_analogclock: /lib/arm-linux-gnueabihf/libc.so.6: version `GLIBC_2.32’ not foun