MilloMille
Posts: 24
Joined: Tue Oct 18, 2016 3:03 pm

Cross Compiling Qt5 for the Raspberry Pi

Fri Nov 04, 2016 9:27 am

Hello guys and girls,
I'm really lost at this one. I am a beginner and wanted to make a GUI for my Touch Screen using Qt5. I couldnt get the QT Designer to work so I asked for help and someone told me that cross compiling would be easier and faster.
So I started to look into cross compiling and I understand basicly nothing. But first here are my specs:
Rasperry Pi B+ with Rasbian 4.4
The Laptop I wanted to use has Linux Mint 17.3 (based on Ubuntu 14.04 ??) installed

I wanted to use this tool to help me cross-compile: https://buildroot.org/ and then basically follow the instructions from this forum viewtopic.php?f=75&t=89518 to set it up (of course with kernel version 4.4 instead of 3.12).
Now my first question is: I have to do all of this on my Raspberry Pi right? Then I will insert the SD Card into my Laptop and can work on a Raspbian immage from the SD card? How do I know I have everything I need for the toolchain? Compiling takes a few hours so it would be really bad if I missed something.

OR:

I could use one of these guides which are directly from QT so I hope the toolchain would be right:
https://wiki.qt.io/RaspberryPi_Beginners_Guide
https://wiki.qt.io/RaspberryPi2EGLFS
But I'm not sure if the first guide will work because it is for Raspbain wheezy and the second guide talks about some eglfs stuff I never heard about

User avatar
topguy
Posts: 6527
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Cross Compiling Qt5 for the Raspberry Pi

Fri Nov 04, 2016 10:22 am

- I would never use the words "cross-compiling" and "easier" in the same sentence. (except right now)
- You know that you can develop your Qt5 application on Linux on your laptop and just copy the code over to compile directly on the Pi ? ( preferrably to use same Qt5 version on both of course )

- Buildroot is something you do on your laptop. And buildroot will actually create a crosscompiler environment as part of the process, but it is for building stuff that will run from the buildroot image.
- But do you want your final application only to run from the buildroot image or do you want to run it on Raspbian ?

The reason "eglfs" is mentioned in those guides is because if you use "eglfs" (OpenGL ES2.0) as "rendering backend" in Qt5 you don't need to run X-windows and you will get a fullscreen hardware accelerated application. (ex: https://www.youtube.com/watch?v=ID9z1iNu7OI )
The standard Qt5 packages in Raspbian dont work with "eglfs" because it would break some other stuff. So those who want to create such applications has to find Qt5 packages from another source or compile their own version.

MilloMille
Posts: 24
Joined: Tue Oct 18, 2016 3:03 pm

Re: Cross Compiling Qt5 for the Raspberry Pi

Fri Nov 04, 2016 11:05 am

Yes!! This would be the best thing ever!
So if i understand correct I can't copy the application as a whole right? I design my GUI on the Laptop and then copy paste the .cpp and .qml code to my Raspberry? I want my App to run on Raspbian.

So the OpenGL ES2.0 only accelerates the application? If so that doesn't seem to by worth the trouble. I could still design fullscreen apps where the user doesn't see anything going on in the background?

User avatar
topguy
Posts: 6527
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Cross Compiling Qt5 for the Raspberry Pi

Fri Nov 04, 2016 11:41 am

I think you have a couple of choices in QtCreator when you create (or import) a project but using "qmake" as the project type (build framework) seems the best idea.
So you would copy all source files including the ".pro" file which describes how to build your project. You don't even have to start QtCreator on the Raspberry, you just run "qmake project_name.pro" and then "make". ( might not need to run qmake everytime either, but at least the first time )

I would suggest that you maybe use github (or something similar) to store your code, then you push your code from your laptop to github and you will just do "git pull" to update your code on the Pi.
Then you dont need to bother with sharing directories and cutting/pasting files in filebrowser.
http://doc.qt.io/qtcreator/creator-version-control.html


> I could still design fullscreen apps where the user doesn't see anything going on in the background?

Yes, and unless you plan to do fancy animations etc. then it probably wont be noticeably different.

MilloMille
Posts: 24
Joined: Tue Oct 18, 2016 3:03 pm

Re: Cross Compiling Qt5 for the Raspberry Pi

Fri Nov 04, 2016 11:56 am

Sounds amazing. Thank you very much for your help

Return to “Beginners”