Important: Please read the Qt Code of Conduct -

Cross compile Qt to work with embedded Linux [Yocto]

  • Hi guys, I hope you are all fine.

    I spent the last 2 weeks trying to cross compile SAM-BA to work with SAMA5D4 process that running Yocto embedded Linux.
    First of all, SAM-BA source code can be found here ( )

    I started by compile SAM-BA on the host machine, and I succeeded. Then start to cross compile SAM-BA by following many tutorials and the last week I focused on

    Since I'm using Yocto I built the sysroot and toolcahin by using this command
    $ bitbake Bandar-Image -c populate_sdk
    which will create a script that will generate all of the necessary files (sysroot and toolchain) on "/opt/poky/2.1.1"

    I configured the terminal for cross compilation by running $ . /opt/poky/2.1.1/environment-setup-cortexa5hf-neon-poky-linux-gnueabi
    $ device=linux-arm-generic-g++
    $ CROSS_COMPILE=arm-poky-linux-gnueabi-
    $ sysroot=/opt/poky-atmel/2.1.1/sysroots/cortexa5hf-neon-poky-linux-gnueabi

    then cd to Qt5.9 dir to run configure file
    $ ./configure -release -opensource -confirm-license -device $device -device-option CROSS_COMPILE=$CROSS_COMPILE -sysroot $sysroot -prefix /usr/local/qt5_targe

    I always get this message:
    Start of Message

    + cd qtbase
    + /home/u77/Qt5.9/qt-everywhere-opensource-src-5.9.0/qtbase/configure -top-level -release -opensource -confirm-license -device linux-arm-generic-g++ -device-option CROSS_COMPILE=arm-poky-linux-gnueabi- -sysroot /opt/poky-atmel/2.1.1/sysroots/cortexa5hf-neon-poky-linux-gnueabi -prefix /usr/local/qt5_targe
    Creating qmake...
    This is the Qt Open Source Edition.
    You have already accepted the terms of the Open Source license.
    Running configuration tests...
    Checking for valid makespec... Note: Also available for Linux: linux-clang linux-icc
    ERROR: Cannot compile a minimal program. The toolchain or QMakeSpec is broken.
    Check config.log for details.

    End of Message

    --config.log messages
    Start of Message

    Command line: -release -opensource -confirm-license -device linux-arm-generic-g++ -device-option CROSS_COMPILE=arm-poky-linux-gnueabi- -sysroot /opt/poky-atmel/2.1.1/sysroots/cortexa5hf-neon-poky-linux-gnueabi -prefix /usr/local/qt5_targe
    executing config test verifyspec
    + cd /home/u77/Qt5.9/qt-everywhere-opensource-src-5.9.0/qtbase/config.tests/common/verifyspec && /home/u77/Qt5.9/qt-everywhere-opensource-src-5.9.0/qtbase/bin/qmake "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared console single_arch" "QMAKE_CFLAGS += --sysroot=/opt/poky-atmel/2.1.1/sysroots/cortexa5hf-neon-poky-linux-gnueabi" "QMAKE_CXXFLAGS += --sysroot=/opt/poky-atmel/2.1.1/sysroots/cortexa5hf-neon-poky-linux-gnueabi" "QMAKE_LFLAGS += --sysroot=/opt/poky-atmel/2.1.1/sysroots/cortexa5hf-neon-poky-linux-gnueabi" -early "CONFIG += cross_compile" /home/u77/Qt5.9/qt-everywhere-opensource-src-5.9.0/qtbase/config.tests/common/verifyspec
    + cd /home/u77/Qt5.9/qt-everywhere-opensource-src-5.9.0/qtbase/config.tests/common/verifyspec && MAKEFLAGS= /usr/bin/make clean && MAKEFLAGS= /usr/bin/make
    > rm -f verifyspec.o
    > rm -f *~ core *.core
    > arm-poky-linux-gnueabi-g++ -c -pipe -mfloat-abi=softfp --sysroot=/opt/poky-atmel/2.1.1/sysroots/cortexa5hf-neon-poky-linux-gnueabi -O2 -std=gnu++11 -Wall -W -fPIC  -I. -I/home/u77/Qt5.9/qt-everywhere-opensource-src-5.9.0/qtbase/mkspecs/devices/linux-arm-generic-g++ -o verifyspec.o verifyspec.cpp
    > arm-poky-linux-gnueabi-g++ -mfloat-abi=softfp --sysroot=/opt/poky-atmel/2.1.1/sysroots/cortexa5hf-neon-poky-linux-gnueabi -Wl,-O1 -o verifyspec verifyspec.o    
    > /opt/poky-atmel/2.1.1/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/5.3.0/real-ld: error: verifyspec uses VFP register arguments, verifyspec.o does not
    > /opt/poky-atmel/2.1.1/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/5.3.0/real-ld: failed to merge target specific data of file verifyspec.o
    > collect2: error: ld returned 1 exit status
    > Makefile:67: recipe for target 'verifyspec' failed
    > make: *** [verifyspec] Error 1

    End of Message
    Thanks in advance.

  • Moderators

    You are mixing hard float with soft float ABIs, but they are incompatible.

    -mfloat-abi=softfp --sysroot=/opt/poky-atmel/2.1.1/sysroots/cortexa5hf-neon-poky-linux-gnueabi

    ABI is set to softp, but you provide "hf" (==hardfloat) sysroot. I suspect that might be the issue. Please modify the mkspecs to use the correct ABI for your platform (probably hard float, judging from the sysroot).

  • Sierdzio, Thanks for your reply

    I added these lines to my qmake.conf

    QMAKE_CFLAGS           += -mfloat-abi=hard -march=armv7-a -mtune=cortex-a5

    and I ran this configure with option "-no-opengl" because I faced error regarding opengl so I ignored it until I can build SAM-BA..
    it generates Makefile for Qt with success. :)
    But, when I tried to install Qt by executing this line


    I got 2 errors

    //your code herearm-poky-linux-gnueabi-g++ -mfloat-abi=softfp --sysroot=/opt/poky-atmel/2.1.2/sysroots/cortexa5hf-neon-poky-linux-gnueabi -Wl,--no-undefined -Wl,--version-script,QtDBus.version -Wl,-O1 -Wl,-z,origin -Wl,-rpath,\$ORIGIN -shared -Wl,-soname, -o .obj/qdbusconnection.o .obj/qdbusconnectioninterface.o .obj/qdbuserror.o .obj/qdbusintegrator.o .obj/qdbusmessage.o .obj/qdbusserver.o .obj/qdbusabstractinterface.o .obj/qdbusinterface.o .obj/qdbusxmlparser.o .obj/qdbusutil.o .obj/qdbusintrospection.o .obj/qdbusabstractadaptor.o .obj/qdbusinternalfilters.o .obj/qdbusmetaobject.o .obj/qdbusxmlgenerator.o .obj/qdbusmisc.o .obj/qdbusargument.o .obj/qdbusreply.o .obj/qdbusmetatype.o .obj/qdbusextratypes.o .obj/qdbuscontext.o .obj/qdbuspendingcall.o .obj/qdbuspendingreply.o .obj/qdbus_symbols.o .obj/qdbusservicewatcher.o .obj/qdbusunixfiledescriptor.o .obj/qdbusvirtualobject.o .obj/moc_qdbusconnectioninterface.o .obj/moc_qdbusconnection.o .obj/moc_qdbusabstractadaptor.o .obj/moc_qdbusvirtualobject.o .obj/moc_qdbusconnection_p.o .obj/moc_qdbusconnectionmanager_p.o .obj/moc_qdbuspendingcall_p.o  -L/home/u77/Qt5.9/qt-everywhere-opensource-src-5.9.0/qtbase/lib -lQt5Core -lpthread -ldbus-1 
    /opt/poky-atmel/2.1.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/5.3.0/real-ld: cannot find -ldbus-1
    collect2: error: ld returned 1 exit status
    Makefile:274: recipe for target '../../lib/' failed
    make[3]: *** [../../lib/] Error 1
    make[3]: Leaving directory '/home/u77/Qt5.9/qt-everywhere-opensource-src-5.9.0/qtbase/src/dbus'
    Makefile:402: recipe for target 'sub-dbus-make_first' failed
    make[2]: *** [sub-dbus-make_first] Error 2
    make[2]: *** Waiting for unfinished jobs....


    make[3]: Leaving directory '/home/u77/Qt5.9/qt-everywhere-opensource-src-5.9.0/qtbase/src/network'
    make[2]: Leaving directory '/home/u77/Qt5.9/qt-everywhere-opensource-src-5.9.0/qtbase/src'
    Makefile:49: recipe for target 'sub-src-make_first' failed
    make[1]: *** [sub-src-make_first] Error 2
    make[1]: Leaving directory '/home/u77/Qt5.9/qt-everywhere-opensource-src-5.9.0/qtbase'
    Makefile:83: recipe for target 'module-qtbase-make_first' failed
    make: *** [module-qtbase-make_first] Error 2

    error log file URL:

  • Moderators

    Interestingly, I can still see -mfloat-abi=softfp there in the first line of your output.

    And analyzing the log, here is how g++ is invoked:

    arm-poky-linux-gnueabi-g++ -c -include .pch/Qt5Network -pipe -mfloat-abi=softfp -pipe -mfloat-abi=softfp -mfloat-abi=hard

    However, the error you are getting is about a missing dependency: linker can't find dbus library in your system/ toolchain.

  • Thanks Sierdzio, I included the dbus to the rootfs..and it solved Error#1
    but I still getting error#2

    arm-poky-linux-gnueabi-g++ -mfloat-abi=softfp --sysroot=/opt/poky-atmel/2.1.3/sysroots/cortexa5hf-neon-poky-linux-gnueabi -Wl,-O1 -Wl,-z,origin -Wl,-rpath,\$ORIGIN/../../../../lib -o tooltips .obj/main.o .obj/shapeitem.o .obj/sortingbox.o .obj/qrc_tooltips.o .obj/moc_sortingbox.o   -L/home/u77/Qt5.9/qt-everywhere-opensource-src-5.9.0/qtbase/lib -lQt5Widgets -lQt5Gui -lQt5Core -lpthread 
    make[5]: Leaving directory '/home/u77/Qt5.9/qt-everywhere-opensource-src-5.9.0/qtbase/examples/widgets/widgets/tooltips'
    make[5]: Leaving directory '/home/u77/Qt5.9/qt-everywhere-opensource-src-5.9.0/qtbase/examples/widgets/widgets/tetrix'
    make[4]: Leaving directory '/home/u77/Qt5.9/qt-everywhere-opensource-src-5.9.0/qtbase/examples/widgets/widgets'
    make[3]: Leaving directory '/home/u77/Qt5.9/qt-everywhere-opensource-src-5.9.0/qtbase/examples/widgets'
    make[2]: Leaving directory '/home/u77/Qt5.9/qt-everywhere-opensource-src-5.9.0/qtbase/examples'
    Makefile:74: recipe for target 'sub-examples-make_first' failed
    make[1]: *** [sub-examples-make_first] Error 2
    make[1]: Leaving directory '/home/u77/Qt5.9/qt-everywhere-opensource-src-5.9.0/qtbase'
    Makefile:83: recipe for target 'module-qtbase-make_first' failed
    make: *** [module-qtbase-make_first] Error 2

    I searched for keywords, such as (cannot, no such file, exist, not, error, failed ..) but I couldn't find something obvious to me :(.

    error log file URL:

  • Moderators

    Do a clean rebuild (delete your build dir, run configure again, then make), because this output does not show any actual error message or what has failed. When configuring Qt, run it without examples, too (add -nomake examples to configure).

    Also, add -mfloat-abi=hard to linker commands, in addition to C and CXX flags you already have added.

  • Thanks for reply, I got error on missing libs.
    working on it, if it build with success I'll post here.

Log in to reply