Qt Cross Compile 6.4.0 CMake generation or configuration mismatch
-
Hi,
I'm trying to compile Qt for x86_64 Linux (Ubuntu 22.04) host and Beagle Bone Black armv7 (Debian 10) target platform.
I was following Qt6 for RPI guide.
(https://wiki.qt.io/Cross-Compile_Qt_6_for_Raspberry_Pi)I successfully compiled x86_64 (for self) kit. After that, I customized toolkit.cmake file, sysroot, build directory etc. and tried to compile cross version. Eventhough I set my C and C++ compiler at toolkit.cmake and set on configure macro, CMAKE build system automatically selects x86_64 compiler default installed on my host machine.
My toolkit.cmake :
cmake_minimum_required(VERSION 3.18) include_guard(GLOBAL) set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_PROCESSOR arm) set(TARGET_SYSROOT /home/atlas/qt-for-BBB/BBB-sysroot) set(CMAKE_SYSROOT ${TARGET_SYSROOT}) set(ENV{PKG_CONFIG_PATH} $PKG_CONFIG_PATH:/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}) # if you use other version of gcc and g++ than gcc/g++ 9, you must change the following variables set(CMAKE_C_COMPILER /opt/gcc-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc) set(CMAKE_CXX_COMPILER /opt/gcc-arm-linux-gnueabihf/bin/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") 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/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(GLIB_LIBRARY ${XCB_PATH_VARIABLE}/usr/lib/arm-linux-gnueabihf/libGLESv2.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)
Configuration commands (i tried more than one):
1-
../qt5/configure -release -opengl es2 -nomake examples -nomake tests -qt-host-path /home/atlas/qt-for-BBB/qt-host -extprefix /home/atlas/qt-for-BBB/qt-BBB -prefix /usr/local/qt6 -device linux-beagleboard-g++ -device-option CROSS_COMPILE=/opt/gcc-arm-linux-gnueabihf/bin/arm-linux-gnueabihf- -DCMAKE_TOOLCHAIN_FILE=/home/atlas/qt-for-BBB/toolchain.cmake -DQT_FEATURE_xcb=ON -DFEATURE_xcb_xlib=ON -DQT_FEATURE_xlib=ON
2- I copied ./qt5/qtbase/mkspecs/devices/linux-arm-gnueabi-g++ as ./qt5/qtbase/mkspecs/devices/linux-arm-gnueabihf-g++ and set the compiler, then run this
../qt5/configure -release -opengl es2 -nomake examples -nomake tests -qt-host-path /home/atlas/qt-for-BBB/qt-host -extprefix /home/atlas/qt-for-BBB/qt-BBB -prefix /usr/local/qt6 -platform linux-g++ -xplatform linux-arm-gnueabihf-g++ -device linux-beagleboard-g++ -device-option CROSS_COMPILE=/opt/gcc-arm-linux-gnueabihf/bin/arm-linux-gnueabihf- -DCMAKE_TOOLCHAIN_FILE=/home/atlas/qt-for-BBB/toolchain.cmake -DQT_FEATURE_xcb=ON -DFEATURE_xcb_xlib=ON -DQT_FEATURE_xlib=ON
these are resulting same and default using x86_64 compiler.
at the output below as you can see, CMAKE sets compiler as host compiler...
➜ qtBBB-build ../qt5/configure -release -opengl es2 -nomake examples -nomake tests -qt-host-path /home/atlas/qt-for-BBB/qt-host -extprefix /home/atlas/qt-for-BBB/qt-BBB -prefix /usr/local/qt6 -device linux-beagleboard-g++ -device-option CROSS_COMPILE=/opt/gcc-arm-linux-gnueabihf/bin/arm-linux-gnueabihf- -DCMAKE_TOOLCHAIN_FILE=/home/atlas/qt-for-BBB/toolchain.cmake -DQT_FEATURE_xcb=ON -DFEATURE_xcb_xlib=ON -DQT_FEATURE_xlib=ON + mkdir -p qtbase + cd qtbase + exec /home/atlas/qt-for-BBB/qt5/qtbase/configure -top-level -release -opengl es2 -nomake examples -nomake tests -qt-host-path /home/atlas/qt-for-BBB/qt-host -extprefix /home/atlas/qt-for-BBB/qt-BBB -prefix /usr/local/qt6 -device linux-beagleboard-g++ -device-option CROSS_COMPILE=/opt/gcc-arm-linux-gnueabihf/bin/arm-linux-gnueabihf- -DCMAKE_TOOLCHAIN_FILE=/home/atlas/qt-for-BBB/toolchain.cmake -DQT_FEATURE_xcb=ON -DFEATURE_xcb_xlib=ON -DQT_FEATURE_xlib=ON opt: for-BBB/toolchain.cmake val: qt '/usr/bin/cmake' '-DQT_HOST_PATH=/home/atlas/qt-for-BBB/qt-host' '-DCMAKE_INSTALL_PREFIX=/usr/local/qt6' '-DCMAKE_STAGING_PREFIX=/home/atlas/qt-for-BBB/qt-BBB' '-DQT_QMAKE_TARGET_MKSPEC=devices/linux-beagleboard-g++' '-DQT_BUILD_EXAMPLES=FALSE' '-DQT_BUILD_TESTS=FALSE' '-DCMAKE_BUILD_TYPE=Release' '-DQT_QMAKE_DEVICE_OPTIONS=CROSS_COMPILE=/opt/gcc-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-' '-DQT_EXTRA_DEFINES=CMAKE_TOOLCHAIN_FILE=/home/atlas/qt-for-BBB/toolchain.cmake;QT_FEATURE_xcb=ON;FEATURE_xcb_xlib=ON;QT_FEATURE_xlib=ON' '-DINPUT_opengl=es2' '-G' 'Ninja' '/home/atlas/qt-for-BBB/qt5' -- The CXX compiler identification is GNU 11.3.0 -- The C compiler identification is GNU 11.3.0 -- The ASM compiler identification is GNU -- Found assembler: /usr/bin/cc -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done Checking dependencies of submodule 'qtbase' Checking dependencies of submodule 'qtimageformats' Checking dependencies of submodule 'qtlanguageserver'
Am I doing something wrong or missing something ?