Integrate Qt Application into Image Build process

I have a working cross-compile setup with Qt Creator and the qt5 toolchain.

Now i would like to integrate the application directly into the image build process. We have a QT5 application, using the qt-plugins serialport and websockets. The application itself runs perfectly on our modified linux system (so all libs are included).

Unfortunately, there aren’t much examples out there, but from some recipes in different layers I was able to create the following recipe:

PR = "2.0"

DEPEMDS = "qtbase qtbase-plugins qtdeclarative qtdeclarative-plugins qtserialport qtwebsockets"

inherit systemd cmake_qt5

SRCREV = "21af9a4e4a8237f78719d57bb659c4453dc77050"
SRC_URI = "git://;protocol=ssh;branch=master"
SRC_URI += "file:// \
            file://app.service \
S = "${WORKDIR}/git"

require recipes-qt/qt5/

do_install () {
	install -d ${D}${systemd_unitdir}/system/ ${D}${sysconfdir}/systemd/system/
	install -m 0644 ${WORKDIR}/app.service ${D}${systemd_unitdir}/system/app.service
	ln -s /dev/null ${D}${sysconfdir}/systemd/system/getty@tty1.service

SYSTEMD_SERVICE_${PN} = "app.service"

Somehow, during the build process, the qt plugins serialport and websockets cannot be found:

ERROR: app-1.0-2.0 do_configure: Error calling /home/christian/oe-core-2.8b3/build/tmp-glibc/work/cortexa9t2hf-neon-angstrom-linux-gnueabi/app/1.0-2.0/recipe-sysroot-native/usr/bin/qt5/qmake -makefile -o Makefile       /home/christian/oe-core-2.8b3/build/tmp-glibc/work/cortexa9t2hf-neon-angstrom-linux-gnueabi/app/1.0-2.0/git/  -- 
ERROR: app-1.0-2.0 do_configure: Function failed: do_configure (log file is located at /home/christian/oe-core-2.8b3/build/tmp-glibc/work/cortexa9t2hf-neon-angstrom-linux-gnueabi/app/1.0-2.0/temp/log.do_configure.864)
ERROR: Logfile of failure stored in: /home/christian/oe-core-2.8b3/build/tmp-glibc/work/cortexa9t2hf-neon-angstrom-linux-gnueabi/app/1.0-2.0/temp/log.do_configure.864
Log data follows:
| DEBUG: Executing shell function qmake5_base_preconfigure
| DEBUG: Shell function qmake5_base_preconfigure finished
| DEBUG: Executing shell function do_configure
| NOTE: qmake prevar substitution: '  '
| Project ERROR: Unknown module(s) in QT: websockets serialport
| ERROR: Error calling /home/christian/oe-core-2.8b3/build/tmp-glibc/work/cortexa9t2hf-neon-angstrom-linux-gnueabi/app/1.0-2.0/recipe-sysroot-native/usr/bin/qt5/qmake -makefile -o Makefile       /home/christian/oe-core-2.8b3/build/tmp-glibc/work/cortexa9t2hf-neon-angstrom-linux-gnueabi/app/1.0-2.0/git/  --
| WARNING: exit code 1 from a shell command.
| ERROR: Function failed: do_configure (log file is located at /home/christian/oe-core-2.8b3/build/tmp-glibc/work/cortexa9t2hf-neon-angstrom-linux-gnueabi/app/1.0-2.0/temp/log.do_configure.864)
ERROR: Task (/home/christian/oe-core-2.8b3/build/../layers/meta-company/recipes-company/app/ failed with exit code '1'
NOTE: Tasks Summary: Attempted 1785 tasks of which 1784 didn't need to be rerun and 1 failed.
NOTE: Writing buildhistory

Summary: 1 task failed:
Summary: There was 1 WARNING message shown.
Summary: There were 2 ERROR messages shown, returning a non-zero exit code.

What I am doing wrong? Did I missed something? Do I need to set additional dependencies?

BR Christian

Hi @cheesi

I’m not sure if this is the only issue but I’ve spotted a typo:

DEPEMDS = "qtbase qtbase-plugins qtdeclarative qtdeclarative-plugins qtserialport qtwebsockets"

should be:

DEPENDS = "qtbase qtbase-plugins qtdeclarative qtdeclarative-plugins qtserialport qtwebsockets"

Please check if this solves your issue. Also try to add an RDEPENDS_${PN} = “…” to make sure the libraries are included in your final image. It will also compile without that but you may have run-time issues.


Hi Stefan!

Thanks, that was one issue. After that, I was still unable to compile it with cmake (Error: could not load cache), however, if I inherit from qmake5 instead, everything works fine. I will stick to that.

Thanks for your help.

BR Christian

Thanks for the feedback.

Qmake is a easier option than using Cmake, since If you use Cmake, you have to do a lot by yourself:

  • running the Meta Object Compiler (MOC)
  • include paths (tell the compiler where to look for Qt headers)
  • linking (tell the linker where to look for Qt libraries)