Simple Hello World application using qt5 for embedded Linux device.
Published at April 1, 2020 · Last Modified at December 23, 2021 · 2 min read · Tags: linux qt5 embedded
Simple Hello World application using qt5 for embedded Linux device.
Published at April 1, 2020 · Last Modified at December 23, 2021 · 2 min read · Tags: linux qt5 embedded
This blog presents a simple example of how to create a qt5 application for a Linux embedded device that runs Wayland or x-server. I’m using Yocto build system. I already have a BSP for IMX8 + toolchain so. I just have to install qt5 on it. In the time that I wrote this page. See here a reference to use Yocto project.
I worked with sumo branch and had to do some work around over three bugs that I found during the compilation of qt5.
The layer meta-qt5 should defined on local/conf/bblayers.conf and the following command should run under the build directory:
bitbake bitbake meta-toolchain-qt5
to install to sdk type under the build directory:
sudo ./tmp/deploy/sdk/fsl-imx-xwayland-glibc-x86_64-meta-toolchain-qt5-aarch64-toolchain-4.14-sumo.sh
when you do it, you can test it:
$ . /opt/fsl-imx-xwayland/4.14-sumo/environment-setup-aarch64-poky-linux
$ echo $CC
aarch64-poky-linux-gcc --sysroot=/opt/fsl-imx-xwayland/4.14-sumo/sysroots/aarch64-poky-linux
I created a straightforward application using qt-creator, and I had to run this command:
. /opt/fsl-imx-xwayland/4.14-sumo/environment-setup-aarch64-poky-linux
before I run qmake & make:
qmake app.pro
make
These two commands should create the ELF file ready to run under the ARM.
QT_QPA_PLATFORM_PLUGIN_PATH=/ptath/to/plugins ./app
In Gentoo desktop, the plugin path is /usr/lib/qt5/plugins/platforms/, so when we install the qt5 libraries that application depends on, we should also install it in the correct location. To install the application as part of an image, we have to write an appropriate bitbabke file that will install all dependencies. See recipes-qt to understand which files it requires to install.
The demo application runs two scripts as a response to a button press: install.sh and reboot.sh, each runs as a child process, and it displays its standard output on the text editor widget.
[1] https://stackoverflow.com/questions/17106315/failed-to-load-platform-plugin-xcb-while-launching-qt5-app-on-linux-without
[2] https://stackoverflow.com/questions/50119427/how-can-i-capture-terminal-output-from-a-bash-script-and-display-it-in-my-qt-ui
[3] https://forum.qt.io/topic/78532/qprocess-execute-capture-output