分享

Configure an Embedded Linux Device | Qt 5.14

 魅影苍穹 2020-02-28

https://doc./qt-5/configure-linux-device.html

Building Qt for a given device requires a toolchain and a sysroot(为嵌入式平台生成Qt,需要工具链和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(在此目录下,查找目标平台对应的-device 参数信息,该信息是必须指定的). 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(以下是一个Pi2的configure示例):

./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(一定要指定-sysroot参数,这样生成Qt时,会从这个指定的参数位置去抽取库,而不是宿主机的库). 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(环境变量PDK_CONFIG_PATH在配置configure之前,宿主机里要保证是没有设置的,不然sysroot的设置会失效). 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(根据需要sysroot的附加参数).

-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(-prefix 指定交叉编译生成的Qt在目标机上会被存放的路径). 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.(使用-extprefix,用于替换生成的Qt默认会被存放的位置sysroot +prefix,以保持sysroot目录的干净) Finally, -hostprefix allows separating host tools like qmake, rcc, uic from the binaries for the target(-hostprefix 用于分离并指定在宿主机上进行目标机开发的工具的安放位置,如qmake,库等). When given, such tools will be installed under the specified directory instead of extprefix.

For more information, see Qt Configure Options.

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多