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

QT cross compile for Raspberry - build environment setup



  • Hello,

    I'm pretty new in QT (I made a few simple applications some time ago to dive into qt).
    Currently, I'm working on my private projects involving STM32 and Raspberry Pi. I have the STM part already done, and now is the time to start with second part.

    What I'm trying to reach?
    Set up the build environment on Ubuntu to be able to compile my program and than deploy it to Raspberry 3B+ running the newest RaspberryPi OS.

    I really like Eclipse and CMake, therefore I would like to set this up with such tools.
    Due to fact, that I'm newbie, I need some help.

    What steps I need to follow?
    Download the QT sources, than run configure with some flags.
    Than make.
    Setup CMake to build executable (than using target_link_libraries link the libraries I used).
    In CMake I should configure which compiler should be used, to build for Rpi.
    After build, I can move the executable to rpi.
    And here the fun begins, because there are no dynamically linked libraries.
    How to handle it? Maybe there is any tutorial handle my case? I did not found how to make it working. The only I found, where with QTCreator - no CMake, Eclipse.


  • Lifetime Qt Champion

    @JackS said in QT cross compile for Raspberry - build environment setup:

    And here the fun begins, because there are no dynamically linked libraries.

    What libraries do you mean?
    https://wiki.qt.io/Raspberry_Pi_Beginners_Guide



  • I was not clear in my first post.

    So, basically I would like to:

    1. Setup CMake to compile my QT application natively on Ubuntu, that will run on Ubuntu. I have built QT 5.12.2 from sources, my app is compiling and running correctly - so this point is OK.
    2. On the same Ubuntu I would like to cross-compile exactly the same application and simple copy the binary directly to Raspberry.

    And I'm getting here into troubles.
    To build application on Ubuntu for Raspberry I need:

    • Compiled QT libraries placed on Raspberry (I can compile those natively on RPi, those libraries will be dynamically linked each time I starting my app);
    • The same libraries as on Raspberry, I need to have on Ubuntu to cross compile my application and CMake should refer somehow to those RPi libraries when building (I can copy libraries from RPi to Ubuntu).
    • The QT-Rpi libraries should not affects the QT-Ubuntu libraries, so should be placed in another place.

    And I'm not sure whether it will work.
    Does anyone has experience with such approach?



  • @JackS said in QT cross compile for Raspberry - build environment setup:

    On the same Ubuntu I would like to cross-compile exactly the same application and simple copy the binary directly to Raspberry.

    Have you checked this useful guide?



  • @Pablo-J-Rogina said in QT cross compile for Raspberry - build environment setup:

    Have you checked this useful guide?

    Not yet.
    At this time seems that it is too complicated for me, and I'm trying to kill mosquito using fridge.
    I choose the way of installing some packages on RPi, that compiling only my application natively on RPi. It is simpler, allows me to compile and run my app separately on Ubuntu and Rpi (over ssh).

    I was able to compile QT for RPi on Ubuntu, but when running CMake there where problems at linking stage with undefined reference to q_source_destroy and some other functions in libQTCore, it complains about missing libgthread, libglib even if CMAKE_SYSROOT was set to sysroot directory prepared during QT compilation (and those two libs were present there).

    I gave up and I'm going to compile my app on RPi directly. It is not a big impact until my app is quite simple. In the future, I probably will have to face this issue again - but I bought some time to learn how it is working...:)



  • I would need assistance as well regarding this topic. I have been struggling for days now to get the cross compile to work so I am giving up. All guides I followed (around 10 different ones) led me back to the starting point. Nothing worked. Is it possible to just develop in Linux or Windows using QtQuick and then just use dependencies on Rpi to make it work? Is it really that complicated? When I run a demo QtQuick app on my Rpi I get that QtQuick is not installed. Before that it was PySide2 but that was easily solved by installing dependencies. Does anyone know what dependencies are required for QtQuick so that an app using QtQuick can run on Rpi?

    Me and my fellow students are under huge pressure with our senior project and we could really use some help. Thank you! We are even considering installing Ubuntu in Rpi to make it run.... :(


Log in to reply