qt5embedded-linuxyoctobitbakeimx6

Yocto: Properly adding support for Qt5 modules with meta-qt5


Context

I'd like to run a Qt application on an IM6 based system with a Yocto built image. I already have the meta-qt5 layer in my project. I started with a simple Qt5 application that only neededs the following modules:

QT += core gui widgets

All I have to do is make sure my bitbake recipe has DEPENDS += qtbase and is based on the qmake class with: inherit qmake5. And it builds and runs on the target! No problem


Problem

Now I'd like to add another Qt5 application, this time with the following modules and one plugin:

QT += core gui widgets    quick qml svg xml network charts
QTPLUGIN += qsvg

Unfortunately, I'm not able to simple add these to my DEPENDS variable and get it to work. But googling around for how to add support reveals what seems to be a sprawling assortment of solutions. I'll enumerate what I've found here:

  1. I need to add inherit populate_sdk_qt5 to instruct bitbake to build the recipe against the SDK that contains the libraries for the modules (see here)
  2. I need to add IMAGE_FEATURES += dev-pkgs to the recipe (see here)
  3. I need to modify local.conf for the system, and add lines like: PACKAGECONFIG_append_pn_qttools = "..." and also PACKAGECONFIG_append_pn-qtbase = "..."
  4. I need to modify layer.conf in my layer and add things like IMAGE_INSTALL_append = "qtbase qtquick ..." (slide 53 here)
  5. I need to manually patch the Qt5 toolchain for charts? (see here)
  6. I need to compile my image using bitbake <target> -c populate_sdk? (see here again)

At this point, I'm really unsure what exactly is going on. It seems we're modifying the recipe, the layer configuration file, the distribution configuration file, and even meta-Qt layer files. I know that I fundamentally need to do a few things:

  1. Compile the application against the Qt5 SDK
  2. Compile the needed plugins + modules for the target architecture
  3. Make sure the appropriate binaries (images) are copied to the target.

But it has become a bit unclear about what does what. I know that IMAGE_INSTALL_append adds images to the target, but I am lost with what is the proper way to add the modules. I don't want to go about randomly adding lines, so I'm hoping someone can clear up a bit what exactly I need to be looking at in order to add support for a Qt5 module for an application.


Solution

  • There are different problems stated, your preferred way seems to the directly building a recipe, not using the toolchain. So, you need the image to have the tools you need.

    First of all qtsvg is not on Qt Base, it is a module so you need it installed.

    Add Qt SVG support

    You need Qt SVG on target in order to run your App. Either to your image or to local.conf you need

    IMAGE_INSTALL_append = " qtsvg" 
    

    As a fact, your app's recipe needs Qt QSVG so you need to DEPEND on it on your app's recipe like this:

    DEPENDS = "qtsvg"
    

    here qtsvg is the name of the other recipe, namely qtsvg_git.bb, not to be confused with the identically named qtsvg plugin. And it will get pulled automatically on build time on your development machine, otherwise it won't even build.

    Remember yocto creates a simulated image tree on the TMP folder in order to build (yes it does it for each recipe), so you must describe what your recipe needs or it won't find it and your build will fail.

    You can also check the recipe for a Qt5 example as it also has DEPENDS and RDEPENDS. And you can get more info on those in here.