Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Cross-compilation with Qt Creator Kits and target SDK - uses target sysroot instead of native



  • Hi,
    Qt 5.15, Linux
    I've got SDK for target HW. Inside are two sysroots - x86_64-pokysdk-linux (native building) and cortexa9t2hf-neon-poky-linux-gnueabi (target libraries) and shell file with bunch of exports (CC, CXX, xxFLAGS, SDKTARGETSYSROOT, etc).
    When I execute above mentioned shell script in console to set environment then create configuration with cmake and build - all is successful.

    So I tried to move to Qt Creator Kit. I set Qt libraries and gcc,g++ from x86_64-pokysdk-linux. Then in Kit tab, in Environment section I copied whole content of above mentioned environment script. And tried to configure project.
    CMake fails on compiling test C/C++ files. Simple errors - due to presence of " in variable setting - has been solved quickly. Still, error

        [2/2] Linking C executable cmTC_6686c
        FAILED: cmTC_6686c 
        : && /home/sebastian/sdk/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc --sysroot=/home/sebastian/sdk/sysroots/cortexa9t2hf-neon-poky-linux-gnueabi -O2 -pipe -g -feliminate-unused-debug-types  -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -fstack-protector-strong -Wl,-z,relro,-z,now   -rdynamic CMakeFiles/cmTC_6686c.dir/testCCompiler.c.o  -o cmTC_6686c   && :
        /home/sebastian/sdk/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.3.0/real-ld: error: cmTC_6686c uses VFP register arguments, CMakeFiles/cmTC_6686c.dir/testCCompiler.c.o does not
        /home/sebastian/sdk/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.3.0/real-ld: failed to merge target specific data of file CMakeFiles/cmTC_6686c.dir/testCCompiler.c.o
    

    I can't resolve.
    I've compared - side to side - CMakeCache.txt generate by Qt Creator and console CMake.
    Noticeable difference was that ie. LINKER in Qt Creator case lead to
    CMAKE_LINKER:FILEPATH=/home/sebastian/sdk/sysroots/cortexa9t2hf-neon-poky-linux-gnueabi/usr/bin/arm-poky-linux-gnueabi-ld
    while in console generate linker was
    CMAKE_LINKER:FILEPATH=/home/sebastian/sdk/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-ld.
    Similar paths differences was visible also for ADDR2LINE, AR, NM, PREFIX_PATH and other more CMake related variables.

    Question is - how to set Qt Creator Kit environment to achieve result as close as possible to the one after execution of environment script in console*?

    PS: Additional note. In Project Build Panel there's by default set -DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}. Qt Binary Libraries provided inside Native sysroot contain QT_INSTALL_<> variables leading to cortexa9 area. Which then is treated as primary point for all CMake path resolution.
    When I removed CMAKE_PREFIX_PATH - make stopped being found. So I looked into CMakeCache.txt for console run and copy&paste -DCMAKE_MAKE_PROGRAM:FILEPATH=/usr/bin/gmake.
    However - despite LINKER (and other apps) paths in CMakeCache leads to native folder (/home/sebastian/sdk/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-ld) - error uses VFP register arguments remain.



  • Current solution is:

    • from Kits section, from CMake parameters remove CMAKE_PREFIX_PATH
    • ensure that CMAKE_MAKE_PROGRAM leads to host OS make (at least for me - I couldn't find make in native sysroot)
    • exports in environment contained export CXX="arm-poky-linux-gnueabi-g++ -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=$SDKTARGETSYSROOT" and separate CXXFLAGS. Given parameter add to Compiler section, C++ entry, Platform codegen flags wasn't taken under consideration, you need to add it explicit to CXXFLAGS in Kit environment section.

    At this moment - CMake built successfully C and CXX test and completed project configuration.
    Project binaries are built and works on target HW.

    PS: Having working console executed building process for comparison is very helpful.


Log in to reply