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

Cross Compilation issue for qt



  • Hello,
    {New to Qt}
    I have installed qt5 on my linux 64 bit pc and would like to build application to stm32 ARM target. But i am facing error in cross compilation. I wrote simple helloworld example and built it through qmake and make. It generated a executable for 64 bit architecture.

    I feel like i am missing something. Please help.

    Thanks.



  • @upendar25

    Hi and welcome to devnet forum

    You need to give some more detailson what you actually did for compiling the hello world application.

    Assuming you are using Qtcreator. Go to Projects on left tool bar. On left pane you should see typically the tool chain chosen indicated in bold.



  • @koahnig

    I have used Qt Creator to compile. i have selected the cross compile toochain which i have installed for my board in compile option and Sysroot option. For the Qt version, i have selected the qmake. It shows an error in Kit saying Qt version is of 64 bit could not produce code for 32 bit device.

    Please let me know if you need some other info.

    Thanks!



  • @upendar25

    For whatever reason you seem to have recompiled Qt for your host platform and the new qmake ist pointing towards the toolchain for the hosting platform and not for your ARM platform.

    Did you follow this guide https://doc.qt.io/qt-5/embedded-linux.html for cross-compilation?



  • @koahnig

    no. I tried to build that way but i got lot of errors and i could not find proper mkspecs file for stm32mp1 board. I installed qt through online installer from their website.

    Please guide me to setup this environment. I have been struggling for 10 days doing different builds and stuff. I am new to this.

    Thank you.



  • @upendar25

    OK, no wonder that you cannot cross-compile your hello world program.
    If there have been a toolchain generated it is for your host and not the target.

    Please give more details about your host machine OS-distro?
    The Qt source version and the location from where?

    Post the problems you encountered while trying to cross-compile.



  • @koahnig

    I am using Ubuntu 16.04 version as host. I am building qt5 for stm32mp1 board.

    I have tried to install Qt5.12 from qt website.

    I am using the linux distribution from ST for this board. Tried to generate qt toolchain with meta-toolchain-qt5 method. But here also i am facing some errors.

    NOTE: Tasks Summary: Attempted 5419 tasks of which 5081 didn't need to be rerun and 3 failed.
    NOTE: Writing buildhistory

    Summary: 3 tasks failed:
    virtual:native:/home/upendar/Data/LinuxSTM/Distribution-Package/openstlinux-4.19-thud-mp1-19-02-20/layers/meta-qt5/recipes-qt/qt5/qt3d_git.bb:do_compile
    virtual:nativesdk:/home/upendar/Data/LinuxSTM/Distribution-Package/openstlinux-4.19-thud-mp1-19-02-20/layers/openembedded-core/meta/recipes-devtools/qemu/qemu_3.0.0.bb:do_compile
    /home/upendar/Data/LinuxSTM/Distribution-Package/openstlinux-4.19-thud-mp1-19-02-20/layers/meta-qt5/recipes-qt/qt5/qtbase_git.bb:do_compile
    .



  • @upendar25

    When I have to do a Qt compilation I am typically using a version from Qt archives https://download.qt.io/archive/qt/ . Those shall be the stablest versions avalable.
    There is also a Git link with all versions. Unfortunately, I do not have the link at hand.

    For compilation on linux you need *.tar.xz e.g. https://download.qt.io/archive/qt/5.12/5.12.3/single/qt-everywhere-src-5.12.3.tar.xz for Qt5.12.3 . The zips are for compilation on windows.

    I have done the cross-compile for RPi based on the guide (link given above). When your device is not part of mkspecs provided by Qt you typically may try the generic ones. Create folders as with other devices (similar to RPi versions) with a name on your desire. This name has to be used in the configure statement.

    Have you downloaded and installed already the cross-compiler for STM device?



  • @koahnig

    Yes. I have installed the cross compiler for STM. I am able to cross compile helloworld program and run on Target.

    I have one doubt. This method with configure, make, make install, do i have to move the built files to my Target? or it creates cross compiler with qt on host PC?



  • @upendar25 take a look at section Qt Creator from RaspberryPi2EGLFS guide to grasp an idea of how "Qt Creator can be set up to build, deploy, run and debug Qt apps directly on the device with one click"


  • Moderators

    @upendar25 said in Cross Compilation issue for qt:

    Yes. I have installed the cross compiler for STM. I am able to cross compile helloworld program and run on Target.
    I have one doubt. This method with configure, make, make install, do i have to move the built files to my Target? or it creates cross compiler with qt on host PC?

    since you say you are able to run your cross compiled exectuable on the target i dont understand what your second question is about?



  • @raven-worx This helloworld program uses GTK module and built by creating a makefile. It works fine. But i am unable to build the same with Qt5. Forthis i need Qt libraries and toolchain to compile qt applications.

    @koahnig

    I have downloaded the qt source and tried to configure for my device. But got the below error.

    Creating qmake...
    make: Nothing to be done for 'first'.
    Command line: -release -release -opengl es2 -device stlinux-arm-gnueabi-g++ -device-option CROSS_COMPILE=/home/upendar/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/x86_64-openstlinux_weston_sdk-linux/usr/bin/arm-openstlinux_weston-linux-gnueabi-gcc -sysroot usr/local -opensource -confirm-license -make libs -nomake tools -nomake examples -nomake tests -skip qt3d -skip qtandroidextras -skip qtcanvas3d -skip qtcharts -skip qtconnectivity -skip qtdatavis3d -skip qtdeclarative -skip qtdoc -skip qtgamepad -skip qtgraphicaleffects -skip qtimageformats -skip qtlocation -skip qtmacextras -skip qtmultimedia -skip qtnetworkauth -skip qtpurchasing -skip qtquickcontrols -skip qtquickcontrols2 -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qtsvg -skip qttools -skip qttranslations -skip qtvirtualkeyboard -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview -skip qtwinextras -skip qtx11extras -skip qtxmlpatterns -no-feature-texthtmlparser -no-feature-textodfwriter -no-feature-concurrent -no-feature-effects -no-feature-sharedmemory -no-feature-systemsemaphore -no-feature-im -no-feature-process -no-feature-dom -no-feature-filesystemmodel -no-feature-filesystemwatcher -no-feature-graphicsview -no-feature-graphicseffect -no-feature-sizegrip -no-feature-calendarwidget -no-feature-printpreviewwidget -no-feature-keysequenceedit -no-feature-colordialog -no-feature-filedialog -no-feature-fontdialog -no-feature-printpreviewdialog -no-feature-progressdialog -no-feature-inputdialog -no-feature-errormessage -no-feature-wizard -no-feature-datawidgetmapper -no-feature-imageformat_bmp -no-feature-imageformat_ppm -no-feature-imageformat_xbm -no-feature-imageformat_png -no-feature-imageformat_jpeg -no-feature-image_heuristic_mask -no-feature-image_text -no-feature-colornames -no-feature-cups -no-feature-paint_debug -no-feature-freetype -no-feature-translation -no-feature-codecs -no-feature-big_codecs -no-feature-iconv -no-feature-ftp -no-feature-udpsocket -no-feature-networkproxy -no-feature-socks5 -no-feature-networkdiskcache -no-feature-bearermanagement -no-feature-completer -no-feature-fscompleter -no-feature-desktopservices -no-feature-mimetype -no-feature-systemtrayicon -no-feature-undocommand -no-feature-undostack -no-feature-undogroup -no-feature-undoview -no-feature-statemachine -no-feature-gestures -no-feature-dbus -v
    Project ERROR: Cannot run target compiler 'arm-linux-gnueabi-g++'. Output:

    ===================
    Maybe you forgot to setup the environment?

    [0_1556909255290_qmake.conf](Uploading 100%)


  • Moderators

    @upendar25 said in Cross Compilation issue for qt:

    -device stlinux-arm-gnueabi-g++

    there is no such device available?
    Did you add it a mkspec for it yourself? If so please show it.

    CROSS_COMPILE=/home/upendar/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/x86_64-openstlinux_weston_sdk-linux/usr/bin/arm-openstlinux_weston-linux-gnueabi-gcc

    should actually look like
    CROSS_COMPILE=/home/upendar/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/x86_64-openstlinux_weston_sdk-linux/usr/bin/arm-openstlinux_weston-linux-gnueabi-

    -sysroot usr/local

    are you sure this is your sysroot? If so it shouldn't it be -sysroot /usr/local?

    also you may want to specify something like -prefix /usr/lib/myqt -hostprefix /home/upendar/myqt. After make install copy everything from /home/upendar/myqt (local) to /usr/lib/myqt (on the target device)



  • @raven-worx Thank you for the detailed reply.

    I am not sure of sysroot. How to find it for a device?

    and I ran the configure command with the changes you specified. I got the following error.

    • arm-openstlinux_weston-linux-gnueabi-g++ -dumpmachine

    arm-openstlinux_weston-linux-gnueabi
    Checking for valid makespec...

    • cd /home/upendar/Data/Qt5/qt-everywhere-src-5.12.3/config.tests/verifyspec && /home/upendar/Data/Qt5/qt-everywhere-src-5.12.3/qtbase/bin/qmake "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_CFLAGS += --sysroot=/usr/local" "QMAKE_CXXFLAGS += --sysroot=/usr/local" "QMAKE_LFLAGS += --sysroot=/usr/local" -early "CONFIG += cross_compile" /home/upendar/Data/Qt5/qt-everywhere-src-5.12.3/qtbase/config.tests/verifyspec
    • cd /home/upendar/Data/Qt5/qt-everywhere-src-5.12.3/config.tests/verifyspec && MAKEFLAGS= /usr/bin/make clean && MAKEFLAGS= /usr/bin/make

    rm -f verifyspec.o
    rm -f *~ core *.core
    arm-openstlinux_weston-linux-gnueabi-g++ -c -pipe --sysroot=/usr/local -O2 -w -fPIC -I/home/upendar/Data/Qt5/qt-everywhere-src-5.12.3/qtbase/config.tests/verifyspec -I. -I/home/upendar/Data/Qt5/qt-everywhere-src-5.12.3/qtbase/mkspecs/devices/stlinux-arm-gnueabi-g++ -o verifyspec.o /home/upendar/Data/Qt5/qt-everywhere-src-5.12.3/qtbase/config.tests/verifyspec/verifyspec.cpp
    arm-openstlinux_weston-linux-gnueabi-g++ --sysroot=/usr/local -Wl,-O1 -o verifyspec verifyspec.o
    /home/upendar/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/x86_64-openstlinux_weston_sdk-linux/usr/libexec/arm-openstlinux_weston-linux-gnueabi/gcc/arm-openstlinux_weston-linux-gnueabi/8.2.0/real-ld: warning: library search path "/usr/local/lib" is unsafe for cross-compilation
    /home/upendar/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/x86_64-openstlinux_weston_sdk-linux/usr/libexec/arm-openstlinux_weston-linux-gnueabi/gcc/arm-openstlinux_weston-linux-gnueabi/8.2.0/real-ld: cannot find crt1.o: No such file or directory
    /home/upendar/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/x86_64-openstlinux_weston_sdk-linux/usr/libexec/arm-openstlinux_weston-linux-gnueabi/gcc/arm-openstlinux_weston-linux-gnueabi/8.2.0/real-ld: cannot find crti.o: No such file or directory
    /home/upendar/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/x86_64-openstlinux_weston_sdk-linux/usr/libexec/arm-openstlinux_weston-linux-gnueabi/gcc/arm-openstlinux_weston-linux-gnueabi/8.2.0/real-ld: cannot find crtbegin.o: No such file or directory
    /home/upendar/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/x86_64-openstlinux_weston_sdk-linux/usr/libexec/arm-openstlinux_weston-linux-gnueabi/gcc/arm-openstlinux_weston-linux-gnueabi/8.2.0/real-ld: cannot find -lstdc++
    /home/upendar/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/x86_64-openstlinux_weston_sdk-linux/usr/libexec/arm-openstlinux_weston-linux-gnueabi/gcc/arm-openstlinux_weston-linux-gnueabi/8.2.0/real-ld: cannot find -lm
    /home/upendar/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/x86_64-openstlinux_weston_sdk-linux/usr/libexec/arm-openstlinux_weston-linux-gnueabi/gcc/arm-openstlinux_weston-linux-gnueabi/8.2.0/real-ld: cannot find -lgcc_s
    /home/upendar/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/x86_64-openstlinux_weston_sdk-linux/usr/libexec/arm-openstlinux_weston-linux-gnueabi/gcc/arm-openstlinux_weston-linux-gnueabi/8.2.0/real-ld: cannot find -lgcc
    /home/upendar/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/x86_64-openstlinux_weston_sdk-linux/usr/libexec/arm-openstlinux_weston-linux-gnueabi/gcc/arm-openstlinux_weston-linux-gnueabi/8.2.0/real-ld: cannot find -lc
    /home/upendar/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/x86_64-openstlinux_weston_sdk-linux/usr/libexec/arm-openstlinux_weston-linux-gnueabi/gcc/arm-openstlinux_weston-linux-gnueabi/8.2.0/real-ld: cannot find -lgcc_s
    /home/upendar/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/x86_64-openstlinux_weston_sdk-linux/usr/libexec/arm-openstlinux_weston-linux-gnueabi/gcc/arm-openstlinux_weston-linux-gnueabi/8.2.0/real-ld: cannot find -lgcc
    /home/upendar/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/x86_64-openstlinux_weston_sdk-linux/usr/libexec/arm-openstlinux_weston-linux-gnueabi/gcc/arm-openstlinux_weston-linux-gnueabi/8.2.0/real-ld: cannot find crtend.o: No such file or directory
    /home/upendar/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/x86_64-openstlinux_weston_sdk-linux/usr/libexec/arm-openstlinux_weston-linux-gnueabi/gcc/arm-openstlinux_weston-linux-gnueabi/8.2.0/real-ld: cannot find crtn.o: No such file or directory
    collect2: error: ld returned 1 exit status
    Makefile:68: recipe for target 'verifyspec' failed
    make: *** [verifyspec] Error 1
    Note: Also available for Linux: linux-clang linux-icc

    ERROR: Cannot compile a minimal program. The toolchain or QMakeSpec is broken.

    My Mkspec file:

    qmake configuration for building with arm-openstlinux_weston-linux-gnueabi-g++

    MAKEFILE_GENERATOR = UNIX
    CONFIG += incremental
    QMAKE_INCREMENTAL_STYLE = sublib

    include(../common/linux.conf)
    include(../common/gcc-base-unix.conf)
    include(../common/g++-unix.conf)

    modifications to g++.conf

    QMAKE_CC = arm-openstlinux_weston-linux-gnueabi-gcc
    QMAKE_CXX = arm-openstlinux_weston-linux-gnueabi-g++
    QMAKE_LINK = arm-openstlinux_weston-linux-gnueabi-g++
    QMAKE_LINK_SHLIB = arm-openstlinux_weston-linux-gnueabi-g++

    modifications to linux.conf

    QMAKE_AR = arm-openstlinux_weston-linux-gnueabi-ar cqs
    QMAKE_OBJCOPY = arm-openstlinux_weston-linux-gnueabi-objcopy
    QMAKE_NM = arm-openstlinux_weston-linux-gnueabi-nm -P
    QMAKE_STRIP = arm-openstlinux_weston-linux-gnueabi-strip
    load(qt_config).

    This i created using a generic file in qtbase/devices. I am not sure its correct but i am going with it.


  • Moderators

    @upendar25 said in Cross Compilation issue for qt:

    I am not sure of sysroot. How to find it for a device?

    a sysroot is a directory structure, similiar to a separate Linux root / structure. Normally this comes along with the cross compiler. It contains the libs for the traget platform the cross-compiler should link against.

    modifications to g++.conf
    modifications to g++.conf

    you are overwriting the compilers. Are those really globally accessible?

    linux_device_pre.conf already contains:

    QMAKE_CC                = $${CROSS_COMPILE}gcc
    QMAKE_CXX               = $${CROSS_COMPILE}g++
    QMAKE_LINK              = $${QMAKE_CXX}
    QMAKE_LINK_SHLIB        = $${QMAKE_CXX}
    

    Which already produces the calls you need with the CROSS_COMPILE variable i suggested.

    I dont know if the cross compiler needs any special parameters/flags? If so only define those within this minimal device:

    include(../common/linux_device_pre.conf)
    
    # QMAKE VARIABLE MODIFICATIONS HERE
    
    include(../common/linux_arm_device_post.conf)
    
    load(qt_config)
    

    Make sure you set the CROSS_COMPILE variable (like you already do).



  • @raven-worx Hi..

    I did these changes. But still there seems to be a problem with configure options.

    ./configure -release -opengl es2 -opensource -confirm-license -device stlinux-arm-gnueabi-g++ -device-option CROSS_COMPILE=/home/upendar/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/sysroots/x86_64-openstlinux_weston_sdk-linux/usr/bin/arm-openstlinux_weston-linux-gnueabi/arm-openstlinux_weston-linux-gnueabi- -sysroot /home/upendar/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-openstlinux_weston-linux-gnueabi -v

    • cd qtbase
    • /home/upendar/STM32MPU_workspace/qt-everywhere-src-5.12.3/qtbase/configure -top-level -release -opengl es2 -opensource -confirm-license -device stlinux-arm-gnueabi-g++ -device-option CROSS_COMPILE=/home/upendar/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/sysroots/x86_64-openstlinux_weston_sdk-linux/usr/bin/arm-openstlinux_weston-linux-gnueabi/arm-openstlinux_weston-linux-gnueabi- -sysroot /home/upendar/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-openstlinux_weston-linux-gnueabi -v
      Creating qmake...
      make: Nothing to be done for 'first'.
      Command line: -release -opengl es2 -opensource -confirm-license -device stlinux-arm-gnueabi-g++ -device-option CROSS_COMPILE=/home/upendar/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/sysroots/x86_64-openstlinux_weston_sdk-linux/usr/bin/arm-openstlinux_weston-linux-gnueabi/arm-openstlinux_weston-linux-gnueabi- -sysroot /home/upendar/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-openstlinux_weston-linux-gnueabi -v
      Project ERROR: Cannot run target compiler '/home/upendar/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/sysroots/x86_64-openstlinux_weston_sdk-linux/usr/bin/arm-openstlinux_weston-linux-gnueabi/arm-openstlinux_weston-linux-gnueabi-g++'. Output:
      ===================
      ===================
      Maybe you forgot to setup the environment?
      .

    echo $CROSS_COMPILE
    arm-openstlinux_weston-linux-gnueabi-

    CROSS_COMPILE is set. Still its not being recognized.


  • Moderators

    @upendar25 said in Cross Compilation issue for qt:

    Project ERROR: Cannot run target compiler '/home/upendar/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/sysroots/x86_64-openstlinux_weston_sdk-linux/usr/bin/arm-openstlinux_weston-linux-gnueabi/arm-openstlinux_weston-linux-gnueabi-g++'.

    can you run it?



  • @raven-worx Surprisingly no. It says no file or directory. But i have that file in that location. I have reinstalled the cross compiler SDK.

    I am able to cross compile using a makefile running it in the SDK environment. But separately with this g++, i am unable to compile a cpp file.


  • Moderators

    @upendar25 said in Cross Compilation issue for qt:

    Surprisingly no. It says no file or directory. But i have that file in that location.

    for sure you are overseeing something here



  • @raven-worx I think so. But i am unable to figure it out.

    I have done the following steps.

    Hardware: STM32MP157c-DK2 with Cortex A7 and M4

    SDK is installed : https://wiki.st.com/stm32mpu/index.php/STM32MP1_Developer_Package#Installing_the_SDK

    Qt12.3 : https://download.qt.io/archive/qt/5.12/5.12.3/single/qt-everywhere-src-5.12.3.tar.xz

    Configure command: ./configure -release -opengl es2 -opensource -confirm-license -device stlinux-arm-gnueabi-g++ -device-option CROSS_COMPILE=/home/upendar/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/sysroots/x86_64-openstlinux_weston_sdk-linux/usr/bin/arm-openstlinux_weston-linux-gnueabi/arm-openstlinux_weston-linux-gnueabi- -sysroot home/upendar/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/sysroots/x86_64-openstlinux_weston_sdk-linux -v
    .

    if someone can point my mistake, it would help me a lot.

    Thank you!


  • Moderators

    @upendar25
    i mean the path is obviously wrong when you can't execute it.
    Check it directory by directory and you will find the mistake. Once you found it adapt the CROSS_COMPILE parameter accordingly.


Log in to reply