Cross-compiling QT 15.2 for Raspberry PI

I lost visible amount of hair over the course of last couple of weeks. All because I had this Idée fixe to develop a cute little GUI app for my Raspberry PI Zero (More about it in the future posts). Web GUI would have been the easiest solution but Chromium is painfully slow on my Raspberry PI Zero. Next option was a standalone app written in either C/C++ or Python. Python + Tkinter sounded promising but objectively…it looks rather ugly and outdated (or I just didn’t put enough effort into it). I didn’t want to use some obscure libraries either as those tend to lack track record and available resources online and my goal was to avoid time waste. So I settled on C++/QT option. Little did I know that I will be spending countless amount of hours for the next 2 weeks trying to fix all the issues QT was generously throwing at me.

My host system is a Windows 10 machine and I didn’t even try to cross-compile from Windows as I knew it would be a difficult endeavor. I started by installing a Lubuntu image in the VirtualBox.

I was following https://mechatronicsblog.com/cross-compile-and-deploy-qt-5-12-for-raspberry-pi/ and official QT Wiki for cross-compilation. Although it is quite a good summary you WILL most probably face issues if you’re not careful enough. Here is some assortment I personally stumbled on.

  • Double, triple check to make sure all paths are correct, that you’re in the correct folder while issuing commands and you have proper access rights. I fell into this trap far more times than I want to admit.
  • Make sure you issue a make clean command after a botched configure or make. Sometime you have to start all over from a clean QT copy by nuking the entire source folder. If you’re seeing messages that something is missing, there is a good chance that you either didn’t install all required packages on target Raspberry and rsync-ed it back to your host or something got corrupted in the QT source repository.
  • At one point during compilation my virtual machine would start accessing disk like a crazy (around 200-300MB/S) and stall. Eventually it would spit following cryptic error message:
internal compiler error killed (program cc1plus)

  • Cleaning the source repository and starting over again didn’t help. It would fail at exactly same spot. Remember I was doing all this on a virtual machine? Well, turns out my virtual disk ran out of space and this is the way my compiler is trying to tell me about it.
  • After compilation is finished you need to add cross-compilation kit to QT Creator. For some reason QT Creator wouldn’t auto detect gcc compiler and was spewing out error messages below. I never really figured out what was going on here but was able to fix it by creating symlinks to cc1 and cc1plus in the same directory with gcc.
Compiler feature detection failure!The command /home/farid/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/bin/gcc -x c++ -E -dM - terminated with exit code 1.
gcc: error trying to exec cc1plus: execvp: No such file or directory
gcc: error trying to exec 'cc1': execvp: No such file or directory
  • I was finally able to build and deploy a test app on my little Raspberry PI and I thought that end of my sufferings. Very quickly I realized that there is some issue with the media playback capability. But that’s a topic for a different post.
Icons: https://icons8.com/icons/pack/arrows. Wallpaper: https://www.itl.cat/wallview/iRwwxbT_raspberry-pi-wallpaper-hd/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: