Linking CXX shared library liblib1.so. FAILED: liblib1.so. bin/ld: cannot find crti.o: No such file or directory. Building Qt6 crosscompiler for Rpi3. Configuring Cmake Qt6 errors
-
I'm trying to build a cross compiler for Raspberry Pi3. The error appears when I try to configure Qt for building next command:
cmake ../src/qtbase-everywhere-src-6.5.1/ -GNinja -DCMAKE_BUILD_TYPE=Release -DINPUT_opengl=es2 -DQT_BUILD_EXAMPLES=OFF -DQT_BUILD_TESTS=OFF -DQT_HOST_PATH=$HOME/qt6/host -DCMAKE_STAGING_PREFIX=$HOME/qt6/pi -DCMAKE_INSTALL_PREFIX=/usr/local/qt6 -DCMAKE_TOOLCHAIN_FILE=$HOME/qt6/toolchain.cmake -DQT_QMAKE_TARGET_MKSPEC=devices/linux-rasp-pi3-g++ -DQT_FEATURE_xcb=ON -DFEATURE_xcb_xlib=ON -DQT_FEATURE_xlib=ON
Errors:
CMake Error at cmake/QtSeparateDebugInfo.cmake:65 (message): Extracted binary path for strip does not exist: Change Dir: /home/user1/qt6/pi-build/config.tests/binary_for_strip_built Run Build Command(s):/usr/bin/ninja && [1/3] Building CXX object CMakeFiles/lib1.dir/lib1.cpp.o [2/3] Linking CXX shared library liblib1.so FAILED: liblib1.so : && /home/user1/qt6/host-t/bin/arm-buildroot-linux-gnueabihf-g++ --sysroot=/home/user1/rpi-sysroot -fPIC -march=armv8-a -I/home/user1/rpi-sysroot/usr/include -I/home/user1/rpi-sysroot/usr/include -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-rpath-link=/home/user1/rpi-sysroot/usr/lib -Wl,-rpath-link=$HOME/qt6/pi/lib -shared -Wl,-soname,liblib1.so -o liblib1.so CMakeFiles/lib1.dir/lib1.cpp.o -Wl,-rpath,/home/user1/rpi-sysroot && : /home/user1/qt6/host-t/bin/../lib/gcc/arm-buildroot-linux-gnueabihf/12.4.0/../../../../arm-buildroot-linux-gnueabihf/bin/ld: cannot find crti.o: No such file or directory /home/user1/qt6/host-t/bin/../lib/gcc/arm-buildroot-linux-gnueabihf/12.4.0/../../../../arm-buildroot-linux-gnueabihf/bin/ld: cannot find -lm: No such file or directory collect2: error: ld returned 1 exit status ninja: build stopped: subcommand failed. Call Stack (most recent call first): cmake/QtSeparateDebugInfo.cmake:114 (qt_internal_try_compile_binary_for_strip) cmake/QtBuildInternals/QtBuildInternalsConfig.cmake:416 (qt_internal_generate_binary_strip_wrapper) CMakeLists.txt:114 (qt_build_repo_begin) -- Configuring incomplete, errors occurred! See also "/home/user1/qt6/pi-build/CMakeFiles/CMakeOutput.log". See also "/home/user1/qt6/pi-build/CMakeFiles/CMakeError.log".
This is toolchain.cmake file:
cmake_minimum_required(VERSION 3.18) include_guard(GLOBAL) set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_PROCESSOR arm) set(CMAKE_C_COMPILER_WORKS 1) set(CMAKE_CXX_COMPILER_WORKS 1) set(TARGET_SYSROOT /home/user1/rpi-sysroot) set(CMAKE_SYSROOT ${TARGET_SYSROOT}) set(ENV{PKG_CONFIG_PATH} $PKG_CONFIG_PATH:${TARGET_SYSROOT}/usr/lib/arm-linux-gnueabihf/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 /home/user1/qt6/host-t/bin/arm-buildroot-linux-gnueabihf-gcc) set(CMAKE_CXX_COMPILER /home/user1/qt6/host-t/bin/arm-buildroot-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=armv8-a") set(QT_COMPILER_FLAGS_RELEASE "-O2 -pipe") set(QT_LINKER_FLAGS "-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-rpath-link=${TARGET_SYSROOT}/usr/lib -Wl,-rpath-link=$HOME/qt6/pi/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 ${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/arm-linux-gnueabihf/:${TARGET_SYSROOT}/usr:${TARGET_SYSROOT}/usr/lib) set(EGL_INCLUDE_DIR ${GL_INC_DIR}) set(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(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)
I take the compilers from the pre-configured for RPi3 and installed buildroot toolchain which is located:
set(CMAKE_C_COMPILER /home/user1/qt6/host-t/bin/arm-buildroot-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER /home/user1/qt6/host-t/bin/arm-buildroot-linux-gnueabihf-g++)Qt6 builded for host located on /home/user1/qt6/host
In the toolchain.cmake file I added next strings for disabling test compilation(because there was TEST app compile bug):
set(CMAKE_C_COMPILER_WORKS 1)
set(CMAKE_CXX_COMPILER_WORKS 1)
But there is an assumption that linking the missing liblib1.so library is somehow connected with test compilation while I disabled test compilation in the cmake file. It seems like the test application build script is still going on. There is no information about the liblib1.so library.
And the second error is connected with the impossibility of finding the crti.o library by the linker ld.
While this library crti.o are present both in the target device's sysroot directory and in the lib Buildroot toolchain directory.
Location crti.o in device sysroot: /home/user1/rpi-sysroot/lib/arm-linux-gnueabihf
Location crti.o in Buildroot toolchain directory: /home/user1/qt6/host-t/arm-buildroot-linux-gnueabihf/sysroot/usr/libHere is the output of the search paths of the linker belonging to Buildroot toolchain:
user1@user1-laptop:~/qt6/pi-build$/home/user1/qt6/host-t/arm-buildroot-linux-gnueabihf/bin/ld --verbose | grep SEARCH_DIR | tr -s ' ;' \\012 SEARCH_DIR("=/home/user1/Downloads/buildroot-2024.02.7/output/host/arm-buildroot-linux-gnueabihf/lib") SEARCH_DIR("=/usr/local/lib") SEARCH_DIR("=/lib") SEARCH_DIR("=/usr/lib")
For search linked libraries in the toolchain.cmake file I add the path to device sysroot where crti.o located in -rpath-link=${TARGET_SYSROOT}/usr/lib/arm-buildroot-linux-gnueabihf:
set(QT_LINKER_FLAGS "-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-rpath-link=${TARGET_SYSROOT}/usr/lib/arm-buildroot-linux-gnueabihf -Wl,-rpath-link=$HOME/qt6/pi/lib")
But it didn't help.
I also tried to specify the path for searching libraries by the linker in export LD_LIBRARY_PATH=/home/user1/qt6/host-t/arm-buildroot-linux-gnueabihf but it also didn't help.
I also tried to add search path with -L flag:set(QT_LINKER_FLAGS "-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-rpath-link=${TARGET_SYSROOT}/usr/lib/arm-buildroot-linux-gnueabihf -Wl,-rpath-link=$HOME/qt6/pi/lib -L${TARGET_SYSROOT}/usr/lib/arm-buildroot-linux-gnueabihf")
I also tried to write the crti.o libraries to the standard linker search paths, but linker does not see the specified -rpath-link or library crti.o in the standard paths.
I also installed another touchchain Crosstool-NG and tried to use compilers with a linker from another set, but there were the same errors.
I easily compile a cross compiler for qt5, but I have been struggling with these errors for a week now, I have tried all the options but I can't configure Qt6 for building.