32bit cross-compilation error building Qt 6.11.0

Tags: , , ,

When cross-building Qt 6.11.0, this error may come up:

[6471/11681] cd /root/build/qtwebengine/src/host && /usr/bin/cmake -DCMAKE_TOOLCHAIN_FILE=/opt/qt/6.11.0/gcc_64/lib/cmake/Qt6/qt.toolchain.cmake -DQT_USE_ORIGINAL_COMPILER=ON -DWEBENGINE_ROOT_BUILD_DIR=/root/build/qtwebengine -DWEBENGINE_ROOT_SOURCE_DIR=/qt/qt5/qtwebengine -DGN_TARGET_CPU=arm -DCMAKE_C_FLAGS= -DCMAKE_CXX_FLAGS= -DQT_FEATURE_qtwebengine_build=OFF -DQT_FEATURE_qtpdf_build=ON -DGCC_LEGACY_SUPPORT=OFF -GNinja -S /qt/qt5/qtwebengine/src/host -B /root/build/qtwebengine/src/host && /usr/bin/cmake -E touch /root/build/qtwebengine/src/host/src/hostBuild-stamp/hostBuild-configure
FAILED: qtwebengine/src/host/src/hostBuild-stamp/hostBuild-configure /root/build/qtwebengine/src/host/src/hostBuild-stamp/hostBuild-configure 
cd /root/build/qtwebengine/src/host && /usr/bin/cmake -DCMAKE_TOOLCHAIN_FILE=/opt/qt/6.11.0/gcc_64/lib/cmake/Qt6/qt.toolchain.cmake -DQT_USE_ORIGINAL_COMPILER=ON -DWEBENGINE_ROOT_BUILD_DIR=/root/build/qtwebengine -DWEBENGINE_ROOT_SOURCE_DIR=/qt/qt5/qtwebengine -DGN_TARGET_CPU=arm -DCMAKE_C_FLAGS= -DCMAKE_CXX_FLAGS= -DQT_FEATURE_qtwebengine_build=OFF -DQT_FEATURE_qtpdf_build=ON -DGCC_LEGACY_SUPPORT=OFF -GNinja -S /qt/qt5/qtwebengine/src/host -B /root/build/qtwebengine/src/host && /usr/bin/cmake -E touch /root/build/qtwebengine/src/host/src/hostBuild-stamp/hostBuild-configure
Re-run cmake no build system arguments
-- The CXX compiler identification is GNU 13.3.0
-- The C compiler identification is GNU 13.3.0
-- 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
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Performing Test HAVE_STDATOMIC
-- Performing Test HAVE_STDATOMIC - Success
-- Found WrapAtomic: TRUE  
CMake Error at CMakeLists.txt:67 (MESSAGE):
  Compiler does not support 32bit compilation

Apparently, the build procedure (QtPdf probably) wants to build tools for the host architecture, and it wants to build it with the same bitness of the target. It may therefore happen when targeting Android armv7a on a x64 machine, for instance. To fix this, you just need to add multiarch support and some 32bit libs. For Ubuntu Noble:

# dpkg --add-architecture i386
# apt-get install -y libc6:i386 \
                     libncurses6:i386 \
                     libstdc++6:i386 \
                     g++-multilib \
                     libc6-dev-i386 \
                     libstdc++-13-dev:i386

Have fun 😉

Leave a Reply

Your email address will not be published. Required fields are marked *