Configure an Embedded Linux Device | Qt 5.14

Qt 5.14 | Configure an Embedded Linux Device

Qt 5.14.1 Reference Documentation

# Configure an Embedded Linux Device

Building Qt for a given device requires a toolchain and a `sysroot`. Additionally, some devices require vendor-specific adaptation code for EGL and OpenGL ES 2.0 support. This is not relevant for non-accelerated platforms, such as those that use the LinuxFB plugin, which is meant for software-based rendering only.

The qtbase/mkspecs/devices directory contains configuration and graphics adaptation code for a number of devices. For example, the `linux-rasp-pi2-g++` mkspec contains build settings such as the optimal compiler and linker flags for the Raspberry Pi 2 device. The mkspec also contains information about either an implementation of the eglfs hooks (vendor-specific adaptation code), or a reference to the suitable eglfs device integration plugin. The device is selected through the configure tool's `-device` parameter. The name that follows after this argument must, at least partially, match one of the subdirectories under devices.

The following is an example configuration for the Raspberry Pi 2. For most Embedded Linux boards, the configure command looks similar:

      ./configure -release -opengl es2 -device linux-rasp-pi2-g++ -device-option CROSS_COMPILE=$TOOLCHAIN/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf- -sysroot $ROOTFS -prefix /usr/local/qt5

The most important parameters are `-device` and `-sysroot`. By specifying `-sysroot`, the include files and libraries used by `configure`'s feature detection tests, as well as Qt itself, are taken from the specified location, instead of the host PC's standard locations. Consequently, installing development packages on the host machine has no relevance. For example, to get `libinput` support, it is not sufficient or necessary to have the `libinput` development headers and libraries installed on the host environment. Instead, the headers and the libraries for the target architecture, such as ARM, must be present in the `sysroot`.

`pkg-config` is supported also when performing cross-compilation. `configure` automatically sets `PKG_CONFIG_LIBDIR` to make `pkg-config` report compiler and linker settings based on the `sysroot` instead of the host machine. This usually functions well without any further adjustments. However, environment variables such as `PKG_CONFIG_PATH` must be unset for the host machine before running `configure`. Otherwise, the Qt build may attempt to use inappropriate headers and libraries from the host system.

Specifying `-sysroot` results in automatically setting the `--sysroot` argument when invoking the compiler. In some cases this is not desirable and can be disabled by passing `-no-gcc-sysroot` to `configure`.

`-prefix`, `-extprefix`, and `-hostprefix` control the intended destination directory of the Qt build. In the above example the ARM build of Qt is expected to be placed in `/usr/local/qt5` on the target device. Note that running `make install` does not deploy anything to the device. Instead, the `install` step targets the directory specified by `extprefix` which defaults to `sysroot` + `prefix` and is therefore optional. However, in many cases "polluting" the sysroot is not desirable and thus specifying `-extprefix` becomes important. Finally, `-hostprefix` allows separating host tools like qmake, rcc, uic from the binaries for the target. When given, such tools will be installed under the specified directory instead of `extprefix`.

For more information, see Qt Configure Options.