QT setup for host and target tutorial that actually works

I have tried every possible tutorial that I could find on the net to setup and compile QT5 for Target and host. I am using the BeagleBone Black and I can generate an image in several ways. At the moment I have an Ubuntu 14.04 with a 4.1.x kernel installed. I also have the QT stuff compiled and installed on the image. I also have a Debian image with the same. This I done with the Yocto project.
So the problem is not to build an image but rather the tool chains and the QT environment on the PC side

I accept that it is always of my own fault that things dont compile and work out, so I dont blame anyone for the failures. I have spent more than a month trying all kinds of recipes and tutorials but none seem to explain in layman’s terms what is required. They explain the steps but I dont have a clear understanding of what is needed to do for the target and what for the host and then how to apply these in the Qt creator environment. There is always a failure of sorts and then you are left in the dark with no one to ask.

My host PC is running Debian 8 (Jessie).

Can anyone recommend a link to a tutorial will help me setup QT5 with Qt creator and the PC and how to get the debug on the target going.
Not the QT documentation please, it is not written to help anyone.

Any help will be appreciated.

Hi Marius,

I understand your frustration, it is indeed quite a maze quest to get things working with qt and yocto.
And I am afraid there is no such thing as a single guide that covers everything for the start.

But still, to me, yocto is the best way to get a qt cross-compile environment.
I have successfully achieved what you describe with a raspberry pi (B, B+ and 2 actually).

So maybe I can help… Where are you stuck ?

What version of yocto do you use ? I would advise against using anything above 1.8.1 for now.
What layers ?
did bitbake whatever-image suceeded ?
I personally use meta-qt5 recipes instead of the yocto ones for qt5. There is an important file to edit in the layer (qbase.inc if my memory is correct), mostly to add “icu” somewhere.
did you bitbake meta-toolchain ?
did you bitbake meta-toolchain-qt5 ?
did you run the setup environnement script (in tmp/deploy/sdk) ?

then there is a trick to get qtcreator working correctly with your cross compiling environment.

Let me know !

Hi Oolav

Thank you for the reply.
I can build any image without any issues on Yocto and I have an image build from this recipe https://blog.guh.guru/tech/crosscompile-qt-5-2-1-for-bbb/
I have also an image build from scott ellis http://www.jumpnowtek.com/beaglebone/BeagleBone-Systems-with-Yocto.html

So the problem is not the image

I need to understand the flow diagram of how to cross compile. When is it target and when is it host. In a nutshell, I need to get QT Creator to work so that I can debug on the target and compile on the host.

I know it sounds silly but the picture is not clear. I need to understand the relationship between target and host and what files belongs where for each. I think I have this mixed up as I get errors that say “cannot execute - format incorrect”

All right ! then you had the worst part done !

[This is way longer than I thought it would be, maybe the start of an actual tutorial here…]

The host is your desktop machine where qtcreator runs.

The target is your BBB.

no tricks there, it will always be that way.
If you are running your desktop in a virtual machine, then you’re desktop is also called a “guest” relatively to your virtual machine’s host (the host of the host) but that’s only if working with VM.

The cross-compile work flow is simple too. on your host you can compile the same source code using either a normal compiler (gcc/g++) of a cross-compiler (arm-poky-linux-gnueabi-g++).
The result of a “normal” compilation is an executable that will run on your “host” machine.
The result of the cross compilation is an executable file made for the ARM processor. If you try to run it on your host machine, it might tell you “cannot execute - format incorrect” because the binary is meant for another processor architecture (x86 / AMD64 …)

you can check the binary information of an executable file with the … “file” command… It can give you something like :
“ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=51665bf2dd325bed09867c8de7da72ceb3955b34, not stripped” … where this is an “ARM” file.

of course QtCreator handles this.
Even sending the ARM binary to your BBB through SSH (you need to include the sftp-server recipe, in your yocto image though).

To qtcreator this is handled in its “Kits”. A Kit is : A qmake + a compiler + a debugger

This is set in the qtcreator options.

For setting up your Kit after building a yocto image you need to do the following :

bitbake meta-toolchain
bitbake meta-toolchain-qt5
cd ./tmp/deploy/sdk

then run every *.sh in there, it will install cross-qmake, cross-compiler and cross-debugger in your /opt/ directory (by default).

in qtcreator’s (options->compile&exec) you can then specify :

  • a new “Qt version” (found for exemple here : /opt/poky/1.7.1/sysroots/x86_64-pokysdk-linux/usr/bin/qt5/qmake)
  • a new compiler (found here :/opt/poky/1.7.1/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++)
  • a new debugger (/opt/poky/1.7.1/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gdb)

(these path need to be adapted to your configuration).

Now if you select the right kit and press “play”, it SHOULD work…

The problem is, there is more to just qmake, g++ and gdb. To crosscompile there needs to be a set of variables set in your “terminal” environment (compiler flags, qmake options, etc…)

in qtcreator you need to specify your environment in the project options.

what I do is :
cd /opt/poky/1.7.1/
source environment-setup-arm1176jzfshf-vfp-poky-linux-gnueabi


i then copy the output of printenv and copy that into the project configuration (what qtcreator calls “batch script”) for the BBB kit in the “compile” section. (see screen capture below )


Then you need to start qtcreator as root, and THEN it should work.

Last thing, you need to have the gdbserver bitbaked in your yocto image in order to remotely debug the target from the host…

hope this helped !


Wow man that is exactly what I was looking for. Now it makes sense and I can see many things that I did wrong. For one, I never did the meta-toolchain make step. I will try this in next day or two and report back.

Thanks a lot Valentin, this is great help.


Hi Valentin
I tried what you said and I got a lot more done. I have issue that I dont seem to understand. I do not have a new
“Qt version” (found for example here : /opt/poky/1.7.1/sysroots/x86_64-pokysdk-linux/usr/bin/qt5/qmake) There is no qt5 directory.

So when I compile it is still for the wrong platform. It compiles for the PC but seemingly not for the ARM.


Hi Marius, I am glad it helped !

Your issue sounds like a failed bitbake meta-toolchain-qt5, no ? If it succeeded, you should find, under the tmp/deploy/sdk directory this king of file :


(in addition to this one :
poky-glibc-x86_64-meta-toolchain-arm1176jzfshf-vfp-toolchain-1.7.1.sh, created by the meta-toolchain recipe)

the “qt5” bash needs to be run, and you should find the qt5 directory inside the /opt/ directory.

Actually you can solely use the meta-toolchain-qt5 which includes the meta-toolchain one… can’t remember why I baked both…

let me know !

Ok it must have failed or I have a qt5 under /opt/poky/2.0.
If I try to load the qmake or qtversion of that directory qtcreator says “exec format error”

Hi Valentin
Same last confusion. I have tried all kinds of setup in qtcreator but no success. It is always that the compiler and the qt version does not match.

Would you be willing to have a look via teamviewer at my setup please? If so, you can pm me for login details.

A very big thank you to Valentin for making a huge effort to help me to get this sorted out. I used the wrong sysroots and some other small setting problems.
He is a great guy thank again.