cross-compiling Qt6: moc: cannot execute binary file
-
Hi,
I'm trying to cross-compile Qt6.1.3 to aarch64 target. host is x86_64 linux.
My procedure is following:
-
build minimal native Qt6 "build" (to get native tools for cross-compile). it is installed in <build dir>/qt6
-
cross-build config i'm setting -qt-host-path to <build dir>/qt6
Issue: cross-build fails with:
Output ------ /home/piotro/minimyth2-aarch64/script/qt/qt6/work/main.d/qt-everywhere-src-6.1.3_build/qtbase/libexec/moc: /home/piotro/minimyth2-aarch64/script/qt/qt6/work/main.d/qt-everywhere-src-6.1.3_build/qtbase/libexec/moc: cannot execute binary file
It look like cross-build is not using tools from <build dir>/qt6 but rather from itself (used moc is for aarch64 so obviously can't be executed on my x86_64 host)
What i'm missing?
FYI: my cross-build config:
cat config.opt -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_FIND_ROOT_PATH=/home/piotro/minimyth2-aarch64/images/main/usr -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY -DCMAKE_C_COMPILER=//home/piotro/minimyth2-aarch64/images/build/usr/bin/aarch64-minimyth-linux-gnu-gcc -DCMAKE_CXX_COMPILER=//home/piotro/minimyth2-aarch64/images/build/usr/bin/aarch64-minimyth-linux-gnu-g++ -DCMAKE_AR=//home/piotro/minimyth2-aarch64/images/build/usr/bin/aarch64-minimyth-linux-gnu-ar -DCMAKE_LINKER=//home/piotro/minimyth2-aarch64/images/build/usr/bin/aarch64-minimyth-linux-gnu-ld -DCMAKE_NM=//home/piotro/minimyth2-aarch64/images/build/usr/bin/aarch64-minimyth-linux-gnu-nm -DCMAKE_OBJCOPY=//home/piotro/minimyth2-aarch64/images/build/usr/bin/aarch64-minimyth-linux-gnu-objcopy -DCMAKE_OBJDUMP=//home/piotro/minimyth2-aarch64/images/build/usr/bin/aarch64-minimyth-linux-gnu-objdump -DCMAKE_RANLIB=//home/piotro/minimyth2-aarch64/images/build/usr/bin/aarch64-minimyth-linux-gnu-ranlib -DCMAKE_STRIP=//home/piotro/minimyth2-aarch64/images/build/usr/bin/aarch64-minimyth-linux-gnu-strip -prefix /home/piotro/minimyth2-aarch64/images/main/usr/lib/qt6 -bindir /home/piotro/minimyth2-aarch64/images/main/usr/lib/qt6/bin -libdir /home/piotro/minimyth2-aarch64/images/main/usr/lib/qt6/lib -docdir /home/piotro/minimyth2-aarch64/images/main/usr/lib/qt6/doc -headerdir /home/piotro/minimyth2-aarch64/images/main/usr/lib/qt6/include -datadir /home/piotro/minimyth2-aarch64/images/main/usr/lib/qt6/lib -translationdir /home/piotro/minimyth2-aarch64/images/main/usr/lib/qt6/translations -sysconfdir /home/piotro/minimyth2-aarch64/images/main/usr/lib/qt6/lib/settings -examplesdir /home/piotro/minimyth2-aarch64/images/main/usr/lib/qt6/examples -shared -release -optimize-size -confirm-license -opensource -no-rpath -no-optimized-qmake -platform linux-g++-64-garbuild -xplatform linux-aarch64-gnu-g++-garhost -qt-host-path /home/piotro/minimyth2-aarch64/images/build/usr/lib/qt6 -c++std c++1z -ltcg -plugin-sql-mysql -I /home/piotro/minimyth2-aarch64/images/main/usr/include/mysql -L /home/piotro/minimyth2-aarch64/images/main/usr/lib/mysql -no-sql-db2 -no-sql-ibase -no-sql-oci -no-sql-odbc -no-sql-psql -no-sql-sqlite -no-openvg -nomake examples -nomake tests -skip qtactiveqt -skip qt3d -skip qtandroidextras -skip qtgamepad -skip qtlocation -skip qtlottie -skip qtpurchasing -skip qtquick3d -skip qtquickcontrols -skip qtquickcontrols2 -skip qtquicktimeline -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qttranslations -skip qttools -skip qtwebengine -skip qtvirtualkeyboard -skip qtwinextras -skip qtcoap -skip qtdoc -skip qtmqtt -skip qtopcua -silent -skip qtwebglplugin -opengl es2 -qt-pcre
and my native build config:
cat config.opt -DCMAKE_INSTALL_PREFIX=/home/piotro/minimyth2-aarch64/images/build/usr -DCMAKE_FIND_ROOT_PATH=//home/piotro/minimyth2-aarch64/images/build/usr -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY -DCMAKE_C_COMPILER=//home/piotro/minimyth2-aarch64/images/build/usr/bin/gcc -DCMAKE_CXX_COMPILER=//home/piotro/minimyth2-aarch64/images/build/usr/bin/g++ -DCMAKE_AR=//home/piotro/minimyth2-aarch64/images/build/usr/bin/ar -DCMAKE_LINKER=//home/piotro/minimyth2-aarch64/images/build/usr/bin/ld -DCMAKE_NM=//home/piotro/minimyth2-aarch64/images/build/usr/bin/nm -DCMAKE_OBJCOPY=//home/piotro/minimyth2-aarch64/images/build/usr/bin/objcopy -DCMAKE_OBJDUMP=//home/piotro/minimyth2-aarch64/images/build/usr/bin/objdump -DCMAKE_RANLIB=//home/piotro/minimyth2-aarch64/images/build/usr/bin/ranlib -DCMAKE_STRIP=//home/piotro/minimyth2-aarch64/images/build/usr/bin/strip -prefix //home/piotro/minimyth2-aarch64/images/build/usr/lib/qt6 -bindir //home/piotro/minimyth2-aarch64/images/build/usr/lib/qt6/bin -libdir //home/piotro/minimyth2-aarch64/images/build/usr/lib/qt6/lib -docdir //home/piotro/minimyth2-aarch64/images/build/usr/lib/qt6/doc -headerdir //home/piotro/minimyth2-aarch64/images/build/usr/lib/qt6/include -datadir //home/piotro/minimyth2-aarch64/images/build/usr/lib/qt6/lib -translationdir //home/piotro/minimyth2-aarch64/images/build/usr/lib/qt6/translations -sysconfdir //home/piotro/minimyth2-aarch64/images/build/usr/lib/qt6/lib/settings -examplesdir //home/piotro/minimyth2-aarch64/images/build/usr/lib/qt6/examples -release -confirm-license -opensource -no-rpath -no-optimized-qmake -platform linux-g++-64-garbuild -xplatform linux-g++-64-garhost -c++std c++1z -nomake examples -nomake tests -no-eventfd -no-glib -no-icu -no-openssl -no-opengl -no-dbus -no-pcre -no-sql-db2 -no-sql-ibase -no-sql-mysql -no-sql-oci -no-sql-odbc -no-sql-psql -no-sql-sqlite -qt-zlib -qt-libjpeg -qt-libpng -qt-freetype -qt-pcre -qt-harfbuzz -no-use-gold-linker -make tools -static -optimize-size -no-ltcg -skip qt3d -skip qt5compat -skip qtactiveqt -skip qtcharts -skip qtcoap -skip qtdatavis3d -skip qtdeclarative -skip qtdoc -skip qtimageformats -skip qtlottie -skip qtmqtt -skip qtnetworkauth -skip qtopcua -skip qtquick3d -skip qtquickcontrols2 -skip qtquicktimeline -skip qtscxml -skip qtshadertools -skip qtsvg -skip qttranslations -skip qtvirtualkeyboard -skip qtwayland -skip qttools
-
-
Ok, i found where issue is:
In my project i'm passing config switches to ./configure (qt5 compat. way).
This caused some builder default CMAKE vars were not passed to Qt configure.
Missing -DCMAKE_SYSTEM_NAME="Linux" was turning-off cross-compilation.Now i got cross-compilled Qt6.
Great work with cmake!