Rockchip RK3588 - linux下Qt和opencv交织编译环境搭建

打印 上一主题 下一主题

主题 911|帖子 911|积分 2733

----------------------------------------------------------------------------------------------------------------------------
  开辟板 :NanoPC-T6开辟板eMMC :256GBLPDDR4 :16GB
显示屏 :15.6英寸HDMI接口显示屏u-boot :2017.09linux :6.1
----------------------------------------------------------------------------------------------------------------------------
  本节的目的很简单,介绍两种编译Qt程序的方法;
  

  • 在ubuntu20.04上交织编译Qt程序并在NanoPC-T6开辟板 上部署运行;这种方式需要我们在ubuntu宿主机搭建好Qt交织编译环境,然后在ubuntu宿主机编译Qt程序,并拷贝到开辟板运行;(保举这种方式)
  • 在NanoPC-T6开辟板直接直接编译并运行Qt程序;这种方式需要在开辟板体系搭建好Qt开辟环境,然后在开辟板编译运行;
  在实际项目中,我们一般只选择一种开辟方式,保举第一种。
  一、搭建Qt6交织编译环境

  我们在《移植QT5.6到mini2440》中介绍了交织编译安装Qt,当时使用的版本是qt-everywhere-opensource-src-5.6.0.tar.xz,其支持ARMv4t架构。
  这一节我们计划在ubuntu20.04体系交织编译Qt6安装,编译Qt6需要占用很大的物理磁盘,我们预留30GB以上的物理磁盘。
  在《野火Qt开辟环境》中详细描述了交织编译Qt5、Qt6的流程,在ubuntu宿主机编译不同版本的Qt,对aarch64-linux-gnu的版本有一定的要求,具体如下(务必按照下表要求,否则编译可能出现各种题目);
  开辟板体系捏造机体系捏造机交织编译工具链开辟板编译工具链Qt库版本Ubuntu20.04Ubuntu20.04aarch64-linux-gnu 9.4.0——Qt 5.15.8Debian10Ubuntu20.04aarch64-linux-gnu 8.3.0——Qt 5.15.8/Qt6.2.4Debian11Ubuntu20.04aarch64-none-linux-gnu 10.2.0——Qt 5.15.8Debian11Ubuntu20.04aarch64-linux-gnu-gcc 10.5.0aarch64-linux-gnu 10.2.1Qt 6.5.0  注意:开辟板编译工具链版本要低于或便是捏造机交织编译工具链。
  1.1 ubuntu宿主机预备工作

  1.1.1 安装Qt依靠

  ubunut20.04环境配置,起首,让我们将我们的ubuntu 宿主机更新到最新版本;
  1. root@zhengyang:/opt# sudo apt update
复制代码
接下来,我们将安装一些额外的软件包依靠项。此中一些软件包是编译Qt6所需的构建工具,你可能已经安装了它们,也可能没有;
  1. root@zhengyang:/opt# apt install -y libssl-dev gperf pkg-config git bison ninja-build
  2. root@zhengyang:/opt# apt install  -y build-essential libclang-dev \
  3.    libfontconfig1-dev libfreetype6-dev libx11-dev libx11-xcb-dev \
  4.    libxext-dev libxfixes-dev libxi-dev libxrender-dev libxcb1-dev libxcb-glx0-dev \
  5.    libxcb-keysyms1-dev libxcb-image0-dev libxcb-shm0-dev libxcb-icccm4-dev libxcb-sync-dev \
  6.    libxcb-xfixes0-dev libxcb-shape0-dev libxcb-randr0-dev libxcb-render-util0-dev \
  7.    libxcb-util-dev libxcb-xinerama0-dev libxcb-xkb-dev libxkbcommon-dev libxkbcommon-x11-dev \
  8.    libatspi2.0-dev libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev
  9.    
  10. root@zhengyang:/opt# sudo apt install xcb libxcb-cursor-dev "^libxcb.*"
复制代码
1.1.2 安装交织编译器

  参考《Rockchip RK3588 - 移植uboot 2017.09 & linux 6.1(友善之家脚本方式)》小节《安装交织编译工具》,务必选择第一种方式。
  在测试的时候发现,如果接纳第二种方式在后续交织编译Qt中的编译配置环节中出现各种错误,最终不得不放弃该方式;
  1. ld: error: cannot open crti.o: No such file or directory
  2. cannot find crt1.o
复制代码
1.1.3 CMake安装

  CMake是一个跨平台的构建工具,其支持程度要好于qmake。CMake的配置更加灵活、强大,也更轻易维护。CMak是一个比make更高级的编译配置工具,它可以根据不同平台、不同的编译器,生成相应的Makefile大概vcproj项目。
  Qt6主要保举使用CMake来构建工程,qmake也是支持,但不是主要支持工具。交织编译需要3.16版本以上的cmake.
  接着回到安装目次,拉取源码并解压:
  1. root@zhengyang:/opt# wget https://github.com/Kitware/CMake/releases/download/v3.21.2/cmake-3.21.2.tar.gz
  2. root@zhengyang:/opt# tar -xvf cmake-3.21.2.tar.gz
  3. root@zhengyang:/opt# cd cmake-3.21.2
复制代码
如果下载慢,可以更换为国内镜像:https://521github.com/Kitware/CMake/releases/download/v3.21.2/cmake-3.21.2.tar.gz。
  构建安装CMake:
  1. root@zhengyang:/opt/cmake-3.21.2# apt install openssl libssl-dev  # 安装依赖
  2. root@zhengyang:/opt/cmake-3.21.2# ./configure --prefix=/opt/cmake
  3. root@zhengyang:/opt/opt/cmake-3.21.2# make -j4 &&  make install
  4. root@zhengyang:/opt/cmake-3.21.2# cd ..
  5. root@zhengyang:/opt# rm -rf cmake-3.21.2*
复制代码
这里我们指定了安装路径为/opt/cmake:
  1. root@zhengyang:/opt# cd cmake
  2. root@zhengyang:/opt/cmake#  ls -l
  3. drwxr-xr-x 2 root root 4096 Dec 15 23:26 bin
  4. drwxr-xr-x 3 root root 4096 Dec 15 23:26 doc
  5. drwxr-xr-x 7 root root 4096 Dec 15 23:26 share
  6. root@zhengyang:/opt/cmake# ls -l bin/
  7. -rwxr-xr-x 1 root root 12363720 Dec 15 23:26 ccmake
  8. -rwxr-xr-x 1 root root 12691032 Dec 15 23:26 cmake
  9. -rwxr-xr-x 1 root root 13090144 Dec 15 23:26 cpack
  10. -rwxr-xr-x 1 root root 14331184 Dec 15 23:26 ctest
复制代码
配置环境变量:
  1. root@zhengyang:/opt/cmake# sudo vim /etc/profile
  2. export PATH=$PATH:/opt/cmake/bin
  3. root@zhengyang:/opt/cmake# source /etc/profile
复制代码
检察版本信息:
  1. root@zhengyang:/opt/cmake# cmake --version
  2. cmake version 3.21.2
  3. CMake suite maintained and supported by Kitware (kitware.com/cmake).
复制代码
1.2 debian开辟板预备工作

  debain环境配置,起首,让我们将我们的开辟板debain 体系更新到最新版本;
  1. pi@NanoPC-T6:/# sudo aptitude update
复制代码
1.2.1 安装依靠包

  接下来,从debian软件仓库安装一系列Qt部署到开辟板上所需的依靠包:
  1. # x11相关
  2. pi@NanoPC-T6:/# sudo aptitude install -y libx11-dev freetds-dev libsqlite3-dev libpq-dev libiodbc2-dev firebird-dev libxcb1 libxcb1-dev libx11-xcb1 libx11-xcb-dev libxcb-keysyms1 libxcb-keysyms1-dev libxcb-image0 libxcb-image0-dev libxcb-shm0 libxcb-shm0-dev libxcb-icccm4 libxcb-icccm4-dev libxcb-sync1 libxcb-sync-dev libxcb-render-util0 libxcb-render-util0-dev libxcb-xfixes0-dev libxrender-dev libxcb-shape0-dev libxcb-randr0-dev libxcb-glx0-dev libxi-dev libdrm-dev libxcb-xinerama0 libxcb-xinerama0-dev libatspi2.0-dev libxcursor-dev libxcomposite-dev libxdamage-dev libxss-dev libxtst-dev libpci-dev libcap-dev libxrandr-dev libdirectfb-dev libaudio-dev libxkbcommon-x11-dev
  3. pi@NanoPC-T6:/# sudo aptitude install -y "~n^libxcb" xcb libxcb-cursor-dev      
  4. # gst 1.0相关
  5. pi@NanoPC-T6:/# sudo aptitude install -y libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav qtgstreamer-doc gstreamer1.0-tools libunwind-dev
  6. # 其他等等
  7. pi@NanoPC-T6:/# sudo aptitude install -y libfreetype6-dev libicu-dev libsqlite3-dev libasound2-dev libnss3-dev libxss-dev libxtst-dev libpci-dev libcap-dev libsrtp2-dev libxrandr-dev libdirectfb-dev libaudio-dev libavcodec-dev libavformat-dev libswscale-dev libts-dev libfontconfig1-dev libboost-all-dev libudev-dev libmtdev-dev libxkbcommon-dev mesa-common-dev libpulse-dev libvpx-dev  libsnappy-dev flex bison libxslt-dev ruby gperf libbz2-dev libcups2-dev libatkmm-1.6-dev libxi6 libxcomposite1
  8. pi@NanoPC-T6:/# sudo aptitude install -y libgst-dev libxext-dev libinput-dev libinput-pad-dev
  9. # Opengl相关
  10. pi@NanoPC-T6:/# sudo aptitude install -y libssl-dev libdbus-1-dev libglib2.0-dev libegl1-mesa-dev libgbm-dev libgles2-mesa-dev libgles2-mesa rsyslog  libjpeg-dev
  11. # 检查系统是否有必要的库和依赖项
  12. pi@NanoPC-T6:/# sudo aptitude install -f
复制代码
需要注意的是:上面安装过程中如果找不到包(可以使用sudo aptitude search xxxx查找仓库)大概安装克制,请查找替换包或实行多次尝试。
  我们还将创建一个目次,用于存放针对开辟板的Qt安装。实际上,这可以在从宿主机发送Qt6构建到开辟板之前的任何时候进行,但在本指南中,我们将在此时创建它:
  1. pi@NanoPC-T6:/# sudo mkdir /opt/qt6.5
复制代码
1.2.2 处理Chromium无法打开题目

  安装了上面这些库之后,可能存在debian桌面Chromium浏览器打开失败的题目,具体解决方案如下:
  1. pi@NanoPC-T6:~$ sudo aptitude install chromium chromium-driver chromium-sandbox fonts-liberation libu2f-udev system-config-printer
  2. # 安装语言包,中文
  3. pi@NanoPC-T6:~$ sudo aptitude install chromium-l10n
  4. # 查看版本
  5. pi@NanoPC-T6:~$ chromium --version
  6. Chromium 120.0.6099.109 built on Debian 11.8, running on Debian 11.7
复制代码
1.3 编译前预备

  这里我们使用的版本为qt-everywhere-src-6.5.0.tar.xz,至于为啥不选较低的版本,思量到我们使用的RK3588接纳的Armv8-A架构,低版本的Qt可能并不支持。
  官方安装文档:
  

  • https://doc.qt.io/archives/qt-6.0/linux-requirements.html#platform-plugin-dependencies;
  • https://doc.qt.io/archives/qt-6.0/linux-building.html;
  • 官方编译Qt教程;
  1.3.1 qt-everywhere下载

  在ubuntu体系下载程序包:
  1. root@zhengyang:/opt# mkdir qt6.5
  2. root@zhengyang:/opt# cd qt6.5
  3. root@zhengyang:/opt/qt6.5# wget http://mirrors.ustc.edu.cn/qtproject/official_releases/qt/6.5/6.5.0/single/qt-everywhere-src-6.5.0.tar.xz
复制代码
1.3.2 创建sysroot目次

  在ubuntu20.04上创建sysroot目次,并通过rsync下令将一些目次从开辟板复制到宿主机上,以构建sysroot目次。
  sysroot是包含目的体系焦点文件和库的目次,它是开辟交织编译环境时不可缺少的一部分。
  (1) 起首,确保宿主机和开辟板都安装了rsync。如果尚未安装,可以使用以下下令进行安装:
  1. root@zhengyang:/opt# apt install rsync   # 宿主机
  2. pi@NanoPC-T6:/opt# sudo aptitude install rsync   # 开发板
复制代码
(2) 我们在开辟板debina体系创建sysroot目次;
  1. pi@NanoPC-T6:/opt# sudo mkdir -p /opt/qt6.5/sysroot
  2. pi@NanoPC-T6:/opt/qt6.5# cd /opt/qt6.5/sysroot
  3. pi@NanoPC-T6:/opt/qt6.5/sysroot# sudo mkdir usr
  4. pi@NanoPC-T6:/opt/qt6.5/sysroot# sudo mkdir lib
  5. pi@NanoPC-T6:/opt/qt6.5/sysroot# sudo mkdir opt
  6. pi@NanoPC-T6:/opt/qt6.5/sysroot# sudo cp -arvx /lib/* ./lib
  7. pi@NanoPC-T6:/opt/qt6.5/sysroot# sudo cp -arvx /usr/include ./usr
  8. pi@NanoPC-T6:/opt/qt6.5/sysroot# sudo cp -arvx /usr/lib ./usr
  9. pi@NanoPC-T6:/opt/qt6.5/sysroot# sudo rm -rf /opt/qt6.5/sysroot/usr/lib/modules/6.1.25/
复制代码
在构建完本身的sysroot之后,可能会发现此中的一些符号链接变成了绝对路径,这可能会导致一些题目。为相识决这个题目,使用如下下令将链接路径中的绝对路径/转换为/opt/qt6.5/sysroot:
  1. pi@NanoPC-T6:/opt/qt6.5/sysroot# sudo find -type l -lname '/*' -exec sh -c 'ln -sf "/opt/qt6.5/sysroot$(readlink "$0")" "$0"' {} \;
复制代码
效果如下:
  1. lrwxrwxrwx 1 root root 50 12月 16 21:52 /opt/qt6.5/sysroot/lib/aarch64-linux-gnu/libm.so -> /opt/qt6.5/sysroot/lib/aarch64-linux-gnu/libm.so.6   # 转换前为/lib/aarch64-linux-gnu/libm.so.6
复制代码
为此,我们可以创建一个脚本build_sysroot.sh用于构建sysroot:
  1. sudo mkdir -p /opt/qt6.5/sysroot
  2. cd /opt/qt6.5/sysroot
  3. sudo mkdir usr
  4. sudo mkdir lib
  5. sudo mkdir opt
  6. sudo cp -arvx /lib/* ./lib
  7. sudo cp -arvx /usr/include ./usr
  8. sudo cp -arvx /usr/lib ./usr
  9. sudo rm -rf /opt/qt6.5/sysroot/usr/lib/modules/6.1.25/
  10. sudo find -type l -lname '/*' -exec sh -c 'ln -sf "/opt/qt6.5/sysroot$(readlink "$0")" "$0"' {} \;
  11. ls /opt/qt6.5/sysroot/lib/aarch64-linux-gnu/libm.so -l
复制代码
(3) 在ubuntu宿主机使用rsync下令将开辟板上的/opt/qt6.5/sysroot目次同步到宿主机的/opt/qt6.5/sysroot目次中:
  1. root@zhengyang:/opt/qt6.5# rsync -avzS --rsync-path="sudo rsync" --delete pi@192.168.0.101:/opt/qt6.5/sysroot ./
  2. root@zhengyang:/opt/qt6.5# cd sysroot
  3. root@zhengyang:/opt/qt6.5/sysroot# ll
  4. drwxr-xr-x 83 root root 4096 Dec 16 16:08 lib/
  5. drwx------  2 root root 4096 Dec 16 16:11 opt/
  6. drwx------  2 root root 4096 Dec 16 16:11 usr/
复制代码
此中:
  

  • rsync下令用于从远程机器同步文件到本地机器;
  • -avz表示以归档模式(包括递归、保留权限、保留时间戳和保留链接)、压缩和显示进度等选项同步文件;
  • --rsync-path="sudo rsync"表示在远程机器上使用sudo权限运行rsync下令,以便拥有须要的读取权限来同步某些文件;
  • -delete表示将删除本地机器上不存在于远程机器上的文件;
  • 192.168.0.101为开辟板的IP地点。
  (4) 最终的效果是:将开辟板上的/lib、/usr/include、/usr/lib目次同步到宿主机上的/opt/qt6.5/sysroot目次中。
  在完成全部设置过程之后,我们终于可以开始构建Qt6。这将分为两个部分:
  

  • 构建宿主机上的Qt6;
  • 构建目的设备(例如Nano-PC T6开辟板)上的Qt6;
  1.4 编译宿主机Qt6

  1.4.1 编译配置

  在opt/qt目次下创建一个安装目次qt-host、以及构建目次qt-hostbuild;
  1. root@zhengyang:/opt# cd qt6.5
  2. root@zhengyang:/opt/qt6.5# mkdir qt-host
  3. root@zhengyang:/opt/qt6.5# mkdir qt-hostbuild
复制代码
编译配置:
  1. root@zhengyang:/opt/qt6.5# tar -xvf qt-everywhere-src-6.5.0.tar.xz
  2. root@zhengyang:/opt/qt6.5# cd qt-hostbuild
  3. root@zhengyang:/opt/qt6.5/qt-hostbuild# cmake ../qt-everywhere-src-6.5.0/ -GNinja -DCMAKE_BUILD_TYPE=Release  -DINPUT_opengl=es2 -DQT_BUILD_EXAMPLES=OFF -DQT_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=/opt/qt6.5/qt-host  -DQT_FEATURE_xcb=ON -DFEATURE_xcb_xlib=ON -DQT_FEATURE_xlib=ON
  4. .......
  5. --
  6. Qt is now configured for building. Just run 'cmake --build . --parallel'
  7. Once everything is built, you must run 'cmake --install .'
  8. Qt will be installed into '/opt/qt6.5/qt-host'
  9. To configure and build other Qt modules, you can use the following convenience script:
  10.         /opt/qt6.5/qt-host/bin/qt-configure-module
  11. If reconfiguration fails for some reason, try removing 'CMakeCache.txt' from the build directory
  12. -- Configuring done
  13. -- Generating done
  14. -- Build files have been written to: /opt/qt6.5/qt-hostbuild
复制代码
1.4.2 编译安装

  配置完成之后,就可以进行编译和安装了,约莫需要十几到几十分钟:
  1. root@zhengyang:/opt/qt6.5/qt-hostbuild# cmake --build . --parallel -j4
  2. root@zhengyang:/opt/qt6.5/qt-hostbuild# cmake --install .
复制代码
编译完成后,会下载文件到/opt/qt6.5/qt-host目次中,具体根据前面配置的-DCMAKE_INSTALL_PREFIX目次;
  1. root@zhengyang:/opt/qt6.5/qt-hostbuild# ll /opt/qt6.5/qt-host
  2. drwxr-xr-x   2 root root  4096 Dec 16 01:04 bin/
  3. drwxr-xr-x   4 root root  4096 Dec 16 01:04 doc/
  4. drwxr-xr-x 130 root root  4096 Dec 16 01:04 include/
  5. drwxr-xr-x   4 root root 28672 Dec 16 01:04 lib/
  6. drwxr-xr-x   2 root root  4096 Dec 16 01:04 libexec/
  7. drwxr-xr-x   2 root root 12288 Dec 16 01:04 metatypes/
  8. drwxr-xr-x  65 root root  4096 Dec 16 01:04 mkspecs/
  9. drwxr-xr-x   2 root root  4096 Dec 16 01:04 modules/
  10. drwxr-xr-x   2 root root  4096 Dec 16 01:04 phrasebooks/
  11. drwxr-xr-x  27 root root  4096 Dec 16 01:04 plugins/
  12. drwxr-xr-x  25 root root  4096 Dec 16 01:04 qml/
  13. drwxr-xr-x   2 root root 12288 Dec 16 01:04 translations/
复制代码
1.5 交织编译Qt6

  接下来,我们将在宿主机上编译Qt6,并将其安装到开辟板上。配置和构建的指令与为宿主机构建Qt6类似,但是我们需要做一些额外的工作以获得预期的结果。
  1.5.1 创建cmake toolcain文件

  起首,我们要创建本身的CMake工具链文件。这个文件是告急的,它可以链接正确的编译器和库,以便CMake可以生成适用于开辟板的符合的Qt构建。
  在/opt/qt6.5目次下创建一个配置文件toolchain.cmake,文件中指定编译器路径、sysroot路径,编译链接参数等;
  1. cmake_minimum_required(VERSION 3.18)
  2. include_guard(GLOBAL)
  3. set(CMAKE_SYSTEM_NAME Linux)
  4. set(CMAKE_SYSTEM_PROCESSOR arm)
  5. # 配置sysroot
  6. set(TARGET_SYSROOT /opt/qt6.5/sysroot)
  7. set(CMAKE_SYSROOT ${TARGET_SYSROOT})
  8. set(ENV{PKG_CONFIG_PATH} $PKG_CONFIG_PATH:/usr/lib/aarch64-linux-gnu/pkgconfig)
  9. set(ENV{PKG_CONFIG_LIBDIR} /usr/lib/pkgconfig:/usr/share/pkgconfig/:${TARGET_SYSROOT}/usr/lib/aarch64-linux-gnu/pkgconfig:${TARGET_SYSROOT}/usr/lib/pkgconfig)
  10. set(ENV{PKG_CONFIG_SYSROOT_DIR} ${CMAKE_SYSROOT})
  11. # if you use other version of gcc and g++ than gcc/g++ 9, you must change the following variables
  12. set(CMAKE_C_COMPILER /usr/bin/aarch64-linux-gnu-gcc-10)
  13. set(CMAKE_CXX_COMPILER /usr/bin/aarch64-linux-gnu-g++-10)
  14. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${TARGET_SYSROOT}/usr/include")
  15. set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}")
  16. set(QT_COMPILER_FLAGS "-march=armv8-a")
  17. set(QT_COMPILER_FLAGS_RELEASE "-O2 -pipe")
  18. set(QT_LINKER_FLAGS "-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed")
  19. set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
  20. set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
  21. set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
  22. set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
  23. set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
  24. set(CMAKE_BUILD_RPATH ${TARGET_SYSROOT})
  25. include(CMakeInitializeConfigs)
  26. include(CMakeInitializeConfigs)
  27. function(cmake_initialize_per_config_variable _PREFIX _DOCSTRING)
  28.   if (_PREFIX MATCHES "CMAKE_(C|CXX|ASM)_FLAGS")
  29.     set(CMAKE_${CMAKE_MATCH_1}_FLAGS_INIT "${QT_COMPILER_FLAGS}")
  30.         
  31.     foreach (config DEBUG RELEASE MINSIZEREL RELWITHDEBINFO)
  32.       if (DEFINED QT_COMPILER_FLAGS_${config})
  33.         set(CMAKE_${CMAKE_MATCH_1}_FLAGS_${config}_INIT "${QT_COMPILER_FLAGS_${config}}")
  34.       endif()
  35.     endforeach()
  36.   endif()
  37.   if (_PREFIX MATCHES "CMAKE_(SHARED|MODULE|EXE)_LINKER_FLAGS")
  38.     foreach (config SHARED MODULE EXE)
  39.       set(CMAKE_${config}_LINKER_FLAGS_INIT "${QT_LINKER_FLAGS}")
  40.     endforeach()
  41.   endif()
  42.   _cmake_initialize_per_config_variable(${ARGV})
  43. endfunction()
  44. set(XCB_PATH_VARIABLE ${TARGET_SYSROOT})
  45. set(GL_INC_DIR ${TARGET_SYSROOT}/usr/include)
  46. set(GL_LIB_DIR ${TARGET_SYSROOT}:${TARGET_SYSROOT}/usr/lib/aarch64-linux-gnu/:${TARGET_SYSROOT}/usr:${TARGET_SYSROOT}/usr/lib)
  47. set(EGL_INCLUDE_DIR ${GL_INC_DIR})
  48. set(EGL_LIBRARY ${XCB_PATH_VARIABLE}/usr/lib/aarch64-linux-gnu/libEGL.so)
  49. set(OPENGL_INCLUDE_DIR ${GL_INC_DIR})
  50. set(OPENGL_opengl_LIBRARY ${XCB_PATH_VARIABLE}/usr/lib/aarch64-linux-gnu/libOpenGL.so)
  51. set(GLESv2_INCLUDE_DIR ${GL_INC_DIR})
  52. set(GLESv2_LIBRARY ${XCB_PATH_VARIABLE}/usr/lib/aarch64-linux-gnu/libGLESv2.so)
  53. set(gbm_INCLUDE_DIR ${GL_INC_DIR})
  54. set(gbm_LIBRARY ${XCB_PATH_VARIABLE}/usr/lib/aarch64-linux-gnu/libgbm.so)
  55. set(Libdrm_INCLUDE_DIR ${GL_INC_DIR})
  56. set(Libdrm_LIBRARY ${XCB_PATH_VARIABLE}/usr/lib/aarch64-linux-gnu/libdrm.so)
  57. set(XCB_XCB_INCLUDE_DIR ${GL_INC_DIR})
  58. set(XCB_XCB_LIBRARY ${XCB_PATH_VARIABLE}/usr/lib/aarch64-linux-gnu/libxcb.so)
复制代码
设定了sysroot其会对编译和链接过程中,查找头文件和链接库造成影响,cmake设置--sysroot通过CMAKE_SYSROOT配置;
  例如原本默认会从/usr/include目次中搜索头文件、从/usr/lib中搜索依靠库,当设置了--sysroot=/opt/qt6.5/sysroot后则会从/opt/qt6.5/sysroot/usr/include搜索头文件、从/opt/qt6.5/sysroot/usr/lib中搜索依靠库。
  未设置--sysroot设置了--sysroot=dir后头文件搜索路径/usr/include/opt/qt6.5/sysroot/usr/include依靠库搜索路径/usr/lib/opt/qt6.5/sysroot/usr/lib  1.5.2 创建qmake.conf

  既然我们已经有了工具链,交织编译器和sysroot,我们可以继承配置和构建适用于开辟板的Qt。
  在/opt/qt6.5# cd qt-everywhere-src-6.5.0目次下创建qtbase/mkspecs/devices/linux-nanopc-t6-g++/qmake.conf;
  1. root@zhengyang:/opt/qt6.5# cd qt-everywhere-src-6.5.0
  2. root@zhengyang:/opt/qt6.5/qt-everywhere-src-6.5.0# mkdir qtbase/mkspecs/devices/linux-nanopc-t6-g++
  3. root@zhengyang:/opt/qt6.5/qt-everywhere-src-6.5.0# vim qtbase/mkspecs/devices/linux-nanopc-t6-g++/qmake.conf
  4. #
  5. # Generic qmake configuration for building with g++ on Raspberry Pi 4 (64-bit).
  6. #
  7. # Tested with Raspberry Pi OS 64-bit and aarch64 gcc compiler from Debian package repository
  8. #
  9. # A minimal configure line could look something like this:
  10. DISTRO_OPTS            += deb-multi-arch
  11. include(../common/linux_device_pre.conf)
  12. QMAKE_LIBS_EGL         += -lEGL -lGLESv2 -lmali
  13. QMAKE_LIBS_OPENGL_ES2  += -lGLESv2 -lEGL -lmali
  14. QMAKE_CFLAGS            += -march=armv8-a
  15. QMAKE_CXXFLAGS          += $$QMAKE_CFLAGS
  16. QMAKE_INCDIR_POST += \
  17.     $$[QT_SYSROOT]/usr/include \
  18.     $$[QT_SYSROOT]/usr/include/aarch64-linux-gnu
  19. QMAKE_LIBDIR_POST += \
  20.     $$[QT_SYSROOT]/usr/lib \
  21.     $$[QT_SYSROOT]/lib/aarch64-linux-gnu \
  22.     $$[QT_SYSROOT]/usr/lib/aarch64-linux-gnu
  23. QMAKE_RPATHLINKDIR_POST += \
  24.     $$[QT_SYSROOT]/usr/lib \
  25.     $$[QT_SYSROOT]/usr/lib/aarch64-linux-gnu \
  26.     $$[QT_SYSROOT]/lib/aarch64-linux-gnu
  27. # Added line as requested in the comments above
  28. QMAKE_LIBDIR_EGL = $$[QT_SYSROOT]/usr/lib/aarch64-linux-gnu
  29. QMAKE_INCDIR_EGL = $$[QT_SYSROOT]/usr/include
  30. #Not sure if this line really does something or not
  31. # This is, as far as I understand, where the libraries for GLES2 reside
  32. QMAKE_LIBDIR_OPENGL_ES2 = $$[QT_SYSROOT]/usr/lib/aarch64-linux-gnu
  33. QMAKE_INCDIR_OPENGL_ES2 = $$[QT_SYSROOT]/usr/include
  34. EGLFS_DEVICE_INTEGRATION = eglfs_kms
  35. LINKER_FLAGS   += -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed
  36. include(../common/linux_device_post.conf)
  37. load(qt_config)
复制代码
同时在qtbase/mkspecs/devices/linux-nanopc-t6-g++路径下创建qplatformdefs.h文件;
  1. #include "../../linux-g++/qplatformdefs.h"
复制代码
1.5.3 编译配置

  在opt/qt目次下创建一个安装目次qt-nanopi、以及构建目次qt-nanopibuild;
  1. root@zhengyang:/opt/qt6.5# mkdir qt-nanopi
  2. root@zhengyang:/opt/qt6.5# mkdir qt-nanopibuild
复制代码
编译配置(可以使用cmake,也可以使用configure编译,教程使用cmake方式编译):
  1. root@zhengyang:/opt/qt6.5/qt-nanopibuild# cmake ../qt-everywhere-src-6.5.0/ -GNinja -DCMAKE_BUILD_TYPE=Release -DFEATURE_opengles2=ON -DQT_FEATURE_opengl_desktop=OFF -DQT_FEATURE_opengles3=ON -DTEST_opengles31=TRUE -DFEATURE_opengles31=ON  -DTEST_opengles32=TRUE -DFEATURE_opengles32=ON -DQT_BUILD_EXAMPLES=OFF -DQT_BUILD_TESTS=OFF -DQT_HOST_PATH=/opt/qt6.5/qt-host -DCMAKE_STAGING_PREFIX=/opt/qt6.5/sysroot/opt/prefix -DCMAKE_INSTALL_PREFIX=/opt/qt6.5/qt-nanopi -DCMAKE_TOOLCHAIN_FILE=/opt/qt6.5/toolchain.cmake -DQT_QMAKE_TARGET_MKSPEC=devices/linux-nanopc-t6-g++ -DQT_FEATURE_xcb=ON -DFEATURE_xcb_xlib=ON -DQT_FEATURE_xlib=ON -DFEATURE_egl=ON -DFEATURE_egl_x11=ON -DFEATURE_eglfs=ON -DFEATURE_eglfs_mali=ON -DFEATURE_eglfs_x11=ON -DFEATURE_libinput=ON -DFEATURE_qtwebengine_build=OFF
复制代码
此中:
  

  • -DQT_HOST_PATH=/opt/qt6.5/qt-host 该目次是前面编译宿主机Qt6的安装目次,;
  • -DQT_FEATURE_opengles3=ON 开启了opengl es3;
  • -DCMAKE_STAGING_PREFIX=/opt/qt6.5/sysroot/opt/prefix用于指定将构建结果安装到临时安装目次的路径;
  • -DCMAKE_INSTALL_PREFIX=/opt/qt6.5/qt-nanopi指定构建过程中最终安装的目的路径;
  • -DCMAKE_TOOLCHAIN_FILE 是目的的cmake toolcain文件,需要根据本身实际目次修改;
  • -DQT_QMAKE_TARGET_MKSPEC=devices/linux-nanopc-t6-g++ 指定Qt项目构建时使用的qmake规范;
  更多配置选项可以通过cmake ../qt-everywhere-src-6.5.0/ -LH下令检察。
  (1) 如果出现错误,比如eglfs_mali未生效;
  1. CMake Error at qtbase/cmake/QtBuildInformation.cmake:508 (message):
  2.   Feature "eglfs_mali": Forcing to "ON" breaks its condition:
  3.       QT_FEATURE_eglfs AND ( TEST_egl_mali OR TEST_egl_mali_2 )
  4.   Condition values dump:
  5.       QT_FEATURE_eglfs = "ON"
  6.       TEST_egl_mali = ""
  7.       TEST_egl_mali_2 = ""
  8. Call Stack (most recent call first):
  9.   qtbase/cmake/QtFeature.cmake:288 (qt_configure_add_report_error)
  10.   qtbase/cmake/QtFeature.cmake:410 (qt_feature_check_and_save_internal_value)
  11.   qtbase/cmake/QtFeature.cmake:625 (qt_evaluate_feature)
  12.   qtbase/cmake/QtFeature.cmake:594 (qt_feature_module_end)
  13.   qtbase/src/CMakeLists.txt:13 (qt_feature_evaluate_features)
复制代码
可以看到eglfs_mali如果要生效,除了依靠于QT_FEATURE_eglfs,还依靠于TEST_egl_mali或TEST_egl_mali_2;
  TEST_egl_mali生效取决于(qtbase/src/gui/configure.cmake文件):
  1. # egl-mali
  2. qt_config_compile_test(egl_mali
  3.     LABEL "Mali EGL"
  4.     LIBRARIES
  5.         EGL::EGL
  6.     CODE
  7. "#include <EGL/fbdev_window.h>
  8. #include <EGL/egl.h>
  9. #include <GLES2/gl2.h>
  10. int main(void)
  11. {
  12.     /* BEGIN TEST: */
  13. fbdev_window *w = 0;
  14.     /* END TEST: */
  15.     return 0;
  16. }
  17. ")
复制代码
需要在/opt/qt6.5/sysroot/usr/include/EGL目次下创建fbdev_window.h文件:
  1. /*
  2. * This confidential and proprietary software may be used only as
  3. * authorised by a licensing agreement from ARM Limited
  4. * (C) COPYRIGHT 2008-2011 ARM Limited
  5. * ALL RIGHTS RESERVED
  6. * The entire notice above must be reproduced on all authorised
  7. * copies and copies may only be made to the extent permitted
  8. * by a licensing agreement from ARM Limited.
  9. */
  10. /**
  11. * @file fbdev_window.h
  12. * @brief A window type for the framebuffer device (used by egl and tests)
  13. */
  14. #ifndef _FBDEV_WINDOW_H_
  15. #define _FBDEV_WINDOW_H_
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. typedef enum
  20. {
  21.         FBDEV_PIXMAP_DEFAULT = 0,
  22.         FBDEV_PIXMAP_SUPPORTS_UMP = (1<<0),
  23.         FBDEV_PIXMAP_ALPHA_FORMAT_PRE = (1<<1),
  24.         FBDEV_PIXMAP_COLORSPACE_sRGB = (1<<2),
  25.         FBDEV_PIXMAP_EGL_MEMORY = (1<<3)        /* EGL allocates/frees this memory */
  26. } fbdev_pixmap_flags;
  27. typedef struct fbdev_window
  28. {
  29.         unsigned short width;
  30.         unsigned short height;
  31. } fbdev_window;
  32. typedef struct fbdev_pixmap
  33. {
  34.         unsigned int height;
  35.         unsigned int width;
  36.         unsigned int bytes_per_pixel;
  37.         unsigned char buffer_size;
  38.         unsigned char red_size;
  39.         unsigned char green_size;
  40.         unsigned char blue_size;
  41.         unsigned char alpha_size;
  42.         unsigned char luminance_size;
  43.         fbdev_pixmap_flags flags;
  44.         unsigned short *data;
  45.         unsigned int format; /* extra format information in case rgbal is not enough, especially for YUV formats */
  46. } fbdev_pixmap;
  47. #ifdef __cplusplus
  48. }
  49. #endif
  50. #endif
复制代码
参考文章:《RK3588 Qt 交织编译之三:编译eglfs_kms版本 》。
  (2) 我们可以通过config.summary检察我们的配置:
     点击检察代码  
  1. root@zhengyang:/opt/qt6.5/qt-nanopibuild# cat config.summary
  2. Building for: devices/linux-nanopc-t6-g++ (arm64, CPU features: cx16 neon)
  3. Compiler: gcc 10.5.0
  4. Build options:
  5.   Mode ................................... release
  6.   Optimize release build for size ........ no
  7.   Fully optimize release builds (-O3) .... no
  8.   Building shared libraries .............. yes
  9.   Using C standard ....................... C11
  10.   Using C++ standard ..................... C++17
  11.   Using ccache ........................... no
  12.   Using new DTAGS ........................ yes
  13.   Relocatable ............................ yes
  14.   Using precompiled headers .............. yes
  15.   Using Link Time Optimization (LTCG) .... no
  16.   Using Intel CET ........................ no
  17.   Target compiler supports:
  18.     ARM Extensions ....................... NEON
  19.   Sanitizers:
  20.     Addresses ............................ no
  21.     Threads .............................. no
  22.     Memory ............................... no
  23.     Fuzzer (instrumentation only) ........ no
  24.     Undefined ............................ no
  25.   Build parts ............................ libs
  26. Qt modules and options:
  27.   Qt Concurrent .......................... yes
  28.   Qt D-Bus ............................... yes
  29.   Qt D-Bus directly linked to libdbus .... yes
  30.   Qt Gui ................................. yes
  31.   Qt Network ............................. yes
  32.   Qt PrintSupport ........................ yes
  33.   Qt Sql ................................. yes
  34.   Qt Testlib ............................. yes
  35.   Qt Widgets ............................. yes
  36.   Qt Xml ................................. yes
  37. Support enabled for:
  38.   Using pkg-config ....................... yes
  39.   udev ................................... yes
  40.   OpenSSL ................................ yes
  41.     Qt directly linked to OpenSSL ........ no
  42.   OpenSSL 1.1 ............................ yes
  43.   OpenSSL 3.0 ............................ no
  44.   Using system zlib ...................... yes
  45.   Zstandard support ...................... no
  46.   Thread support ......................... yes
  47. Common build options:
  48.   Linker can resolve circular dependencies  yes
  49. Qt Core:
  50.   backtrace .............................. yes
  51.   DoubleConversion ....................... yes
  52.     Using system DoubleConversion ........ no
  53.   GLib ................................... yes
  54.   ICU .................................... yes
  55.   Using system libb2 ..................... no
  56.   Built-in copy of the MIME database ..... yes
  57.   cpp/winrt base ......................... no
  58.   Tracing backend ........................ <none>
  59.   Logging backends:
  60.     journald ............................. no
  61.     syslog ............................... no
  62.     slog2 ................................ no
  63.   PCRE2 .................................. yes
  64.     Using system PCRE2 ................... yes
  65.   CLONE_PIDFD support in forkfd .......... yes
  66.   Application permissions ................ no
  67. Qt Sql:
  68.   SQL item models ........................ yes
  69. Qt Network:
  70.   getifaddrs() ........................... yes
  71.   IPv6 ifname ............................ yes
  72.   libproxy ............................... no
  73.   Linux AF_NETLINK ....................... yes
  74.   DTLS ................................... yes
  75.   OCSP-stapling .......................... yes
  76.   SCTP ................................... no
  77.   Use system proxies ..................... yes
  78.   GSSAPI ................................. no
  79.   Brotli Decompression Support ........... yes
  80.   qIsEffectiveTLD() ...................... yes
  81.     Built-in publicsuffix database ....... yes
  82.     System publicsuffix database ......... yes
  83. Core tools:
  84.   Android deployment tool ................ no
  85.   macOS deployment tool .................. no
  86.   Windows deployment tool ................ no
  87.   qmake .................................. yes
  88. Qt Gui:
  89.   Accessibility .......................... yes
  90.   FreeType ............................... yes
  91.     Using system FreeType ................ yes
  92.   HarfBuzz ............................... yes
  93.     Using system HarfBuzz ................ yes
  94.   Fontconfig ............................. yes
  95.   Image formats:
  96.     GIF .................................. yes
  97.     ICO .................................. yes
  98.     JPEG ................................. yes
  99.       Using system libjpeg ............... yes
  100.     PNG .................................. yes
  101.       Using system libpng ................ yes
  102.   Text formats:
  103.     HtmlParser ........................... yes
  104.     CssParser ............................ yes
  105.     OdfWriter ............................ yes
  106.     MarkdownReader ....................... yes
  107.       Using system libmd4c ............... no
  108.     MarkdownWriter ....................... yes
  109.   EGL .................................... yes
  110.   OpenVG ................................. no
  111.   OpenGL:
  112.     opengl_desktop ....................... no
  113.     OpenGL ES 2.0 ........................ yes
  114.     opengles3 ............................ yes
  115.     OpenGL ES 3.1 ........................ yes
  116.     OpenGL ES 3.2 ........................ yes
  117.   Vulkan ................................. no
  118.   Session Management ..................... yes
  119. Features used by QPA backends:
  120.   evdev .................................. yes
  121.   libinput ............................... yes
  122.   HiRes wheel support in libinput ........ no
  123.   integrityhid ........................... yes
  124.   mtdev .................................. yes
  125.   tslib .................................. yes
  126.   xkbcommon .............................. yes
  127.   X11 specific:
  128.     xlib ................................. yes
  129.     XCB Xlib ............................. yes
  130.     EGL on X11 ........................... yes
  131.     xkbcommon-x11 ........................ yes
  132.     xcb-sm ............................... yes
  133. QPA backends:
  134.   DirectFB ............................... no
  135.   EGLFS .................................. yes
  136.   EGLFS details:
  137.     EGLFS OpenWFD ........................ no
  138.     EGLFS i.Mx6 .......................... no
  139.     EGLFS i.Mx6 Wayland .................. no
  140.     EGLFS RCAR ........................... no
  141.     EGLFS EGLDevice ...................... yes
  142.     EGLFS GBM ............................ yes
  143.     EGLFS VSP2 ........................... no
  144.     EGLFS Mali ........................... yes
  145.     EGLFS Raspberry Pi ................... no
  146.     EGLFS X11 ............................ yes
  147.   LinuxFB ................................ yes
  148.   VNC .................................... yes
  149.   VK_KHR_display ......................... no
  150.   QNX:
  151.     lgmon ................................ no
  152.     IMF .................................. no
  153.   XCB:
  154.     Using system-provided xcb-xinput ..... no
  155.     GL integrations:
  156.       GLX Plugin ......................... no
  157.         XCB GLX .......................... no
  158.       EGL-X11 Plugin ..................... yes
  159.   Windows:
  160.     Direct 2D ............................ no
  161.     Direct 2D 1.1 ........................ no
  162.     DirectWrite .......................... no
  163.     DirectWrite 3 ........................ no
  164. Qt Widgets:
  165.   GTK+ ................................... no
  166.   Styles ................................. Fusion Windows
  167. Qt Testlib:
  168.   Tester for item models ................. yes
  169.   Batch tests ............................ no
  170. Qt PrintSupport:
  171.   CUPS ................................... yes
  172. Qt Sql Drivers:
  173.   DB2 (IBM) .............................. no
  174.   InterBase .............................. yes
  175.   MySql .................................. no
  176.   OCI (Oracle) ........................... no
  177.   ODBC ................................... yes
  178.   PostgreSQL ............................. yes
  179.   SQLite ................................. yes
  180.     Using system provided SQLite ......... no
  181. Further Image Formats:
  182.   JasPer ................................. no
  183.   MNG .................................... no
  184.   TIFF ................................... yes
  185.     Using system libtiff ................. yes
  186.   WEBP ................................... yes
  187.     Using system libwebp ................. no
  188. Qt QML:
  189.   QML network support .................... yes
  190.   QML debugging and profiling support .... yes
  191.   QML just-in-time compiler .............. yes
  192.   QML XML http request ................... yes
  193.   QML Locale ............................. yes
  194. Qt QML Models:
  195.   QML list model ......................... yes
  196.   QML delegate model ..................... yes
  197. Qt Quick:
  198.   AnimatedImage item ..................... yes
  199.   Canvas item ............................ yes
  200.   Support for Qt Quick Designer .......... yes
  201.   Flipable item .......................... yes
  202.   GridView item .......................... yes
  203.   ListView item .......................... yes
  204.   TableView item ......................... yes
  205.   TreeView item .......................... yes
  206.   Path support ........................... yes
  207.   PathView item .......................... yes
  208.   Positioner items ....................... yes
  209.   Repeater item .......................... yes
  210.   ShaderEffect item ...................... yes
  211.   Sprite item ............................ yes
  212. Qt Quick Templates 2:
  213.   Hover support .......................... yes
  214.   Multi-touch support .................... yes
  215.   Calendar support ....................... yes
  216. Qt Quick Controls 2:
  217.   Styles ................................. Basic Fusion Imagine iOS Material Universal macOS Windows
  218. QtQuick3D:
  219.   Assimp ................................. yes
  220.   System Assimp .......................... no
  221. Qt Multimedia:
  222.   Spatial Audio .......................... yes
  223.   Spatial Audio (Quick3D) ................ yes
  224.   Low level Audio Backend:
  225.     ALSA (experimental) .................. no
  226.     PulseAudio ........................... yes
  227.     MMRenderer ........................... no
  228.     CoreAudio ............................ no
  229.     Windows Media SDK .................... no
  230.     Open SLES (Android) .................. no
  231.     Web Assembly ......................... no
  232.   Plugin:
  233.     GStreamer 1.0 ........................ yes
  234.     FFmpeg ............................... yes
  235.     MMRenderer ........................... no
  236.     AVFoundation ......................... no
  237.     Windows Media Foundation ............. no
  238.   Hardware acceleration and features:
  239.     Video for Linux ...................... yes
  240.     VAAPI support ........................ no
  241.     Linux DMA buffer support ............. yes
  242.     VideoToolbox ......................... no
  243. Qt 3D:
  244.   Assimp ................................. yes
  245.   System Assimp .......................... no
  246.   Use SSE2 instructions .................. no
  247.   Use AVX2 instructions .................. no
  248.   Aspects:
  249.     Render aspect ........................ yes
  250.     Input aspect ......................... yes
  251.     Logic aspect ......................... yes
  252.     Animation aspect ..................... yes
  253.     Extras aspect ........................ yes
  254. Qt 3D APIs:
  255.   Vulkan ................................. no
  256. Qt 3D Renderers:
  257.   OpenGL Renderer ........................ yes
  258.   RHI Renderer ........................... yes
  259. Qt3D Geometry Loaders:
  260.   Autodesk FBX ........................... no
  261. Qt 5 Compatibility Libraries:
  262.   iconv .................................. no
  263. Qt Charts Types:
  264.   Area Chart ............................. yes
  265.   Line Chart ............................. yes
  266.   Spline Chart ........................... yes
  267.   Scatter Chart .......................... yes
  268.   Bar Chart .............................. yes
  269.   Pie Chart .............................. yes
  270.   Boxplot Chart .......................... yes
  271.   Candlestick Chart ...................... yes
  272. Qt Axis Types:
  273.   DateTime Axis .......................... yes
  274. Qt Bluetooth:
  275.   BlueZ .................................. no
  276.   BlueZ Low Energy ....................... no
  277.   Linux Crypto API ....................... no
  278.   WinRT Bluetooth API .................... no
  279. Qt Tools:
  280.   Qt Assistant ........................... yes
  281.   QDoc ................................... no
  282.   Clang-based lupdate parser ............. no
  283.   Qt Designer ............................ yes
  284.   Qt Distance Field Generator ............ yes
  285.   Qt Linguist ............................ yes
  286.   pixeltool .............................. yes
  287.   qdbus .................................. yes
  288.   Qt Attributions Scanner ................ yes
  289.   qtdiag ................................. yes
  290.   qtplugininfo ........................... yes
  291. Serial Port:
  292.   ntddmodm ............................... no
  293. WebEngine Repository Build Options:
  294.   Build Ninja ............................ no
  295.   Build Gn ............................... yes
  296.   Jumbo Build ............................ yes
  297.   Developer build ........................ no
  298.   Build QtWebEngine Modules:
  299.     Build QtWebEngineCore ................ no
  300.     Build QtWebEngineWidgets ............. no
  301.     Build QtWebEngineQuick ............... no
  302.   Build QtPdf Modules:
  303.     Build QtPdfWidgets ................... no
  304.     Build QtPdfQuick ..................... no
  305.   Optional system libraries:
  306.     re2 .................................. no
  307.     icu .................................. no
  308.     libwebp, libwebpmux and libwebpdemux . no
  309.     opus ................................. no
  310.     ffmpeg ............................... no
  311.     libvpx ............................... no
  312.     snappy ............................... yes
  313.     glib ................................. yes
  314.     zlib ................................. yes
  315.     minizip .............................. no
  316.     libevent ............................. yes
  317.     libxml2 and libxslt .................. yes
  318.     lcms2 ................................ no
  319.     png .................................. yes
  320.     jpeg ................................. yes
  321.     libopenjpeg2 ......................... no
  322.     harfbuzz ............................. no
  323.     freetype ............................. yes
  324.     libpci ............................... yes
  325. Qt Protobuf tools:
  326.   Qt Protobuf generator .................. no
  327. Qt GRPC:
  328.   gRPC support ........................... yes
  329.   Native gRPC support .................... no
  330. Qt GRPC tools:
  331.   Qt GRPC generator ...................... no
  332. Qt Opcua:
  333.   Open62541 .............................. yes
  334.   Unified Automation C++ SDK ............. no
  335.   Support for namespace 0 NodeId names ... yes
  336.   Namespace 0 NodeIds generator .......... no
  337.   Open62541 security support ............. yes
  338.   Support for global discovery server .... yes
  339. Qt Remote Objects:
  340.   High Availability Manager (ham) ........ no
  341. Qt Scxml:
  342.   ECMAScript data model for QtScxml ...... yes
  343. Qt Sensors:
  344.   sensorfw ............................... no
  345.   sensorfw_enabled_with_cmake ............ no
  346. Qt SerialBus:
  347.   Socket CAN ............................. yes
  348.   Socket CAN FD .......................... yes
  349.   SerialPort Support ..................... yes
  350. Qt TextToSpeech:
  351.   Flite .................................. no
  352.   Flite with ALSA ........................ no
  353.   Speech Dispatcher ...................... no
  354. Qt Virtualkeyboard:
  355.   Desktop integration .................... yes
  356.   Built-in layouts ....................... yes
  357.   Key navigation ......................... no
  358.   Retro style as default ................. no
  359.   Sensitive Debug ........................ no
  360.   Cerence ................................ no
  361.     Static Linking ....................... no
  362.     Handwriting .......................... no
  363.       Alphabetic ......................... no
  364.       CJK ................................ no
  365.     XT9 .................................. no
  366.       XT9 Debug .......................... no
  367.       XT9 9-key layouts .................. no
  368.     Bundle resources ..................... no
  369.       Handwriting ........................ no
  370.       XT9 ................................ no
  371.   Hunspell ............................... no
  372.     Using Hunspell copy from 3rdparty/ ... no
  373.   OpenWnn ................................ yes
  374.   MyScript ............................... no
  375.   Language support enabled for:
  376.     Arabic ............................... yes
  377.     Bulgarian ............................ yes
  378.     Czech ................................ yes
  379.     Danish ............................... yes
  380.     German ............................... yes
  381.     Greek ................................ yes
  382.     English GB ........................... yes
  383.     English US ........................... yes
  384.     Spanish .............................. yes
  385.     Spanish Mexico ....................... yes
  386.     Estonian ............................. yes
  387.     Farsi ................................ yes
  388.     Finnish .............................. yes
  389.     French Canada ........................ yes
  390.     French France ........................ yes
  391.     Hebrew ............................... yes
  392.     Hindi ................................ yes
  393.     Croatian ............................. yes
  394.     Hungarian ............................ yes
  395.     Indonesian ........................... yes
  396.     Italian .............................. yes
  397.     Japanese ............................. yes
  398.     Korean ............................... yes
  399.     Malay ................................ yes
  400.     Norwegian ............................ yes
  401.     Dutch ................................ yes
  402.     Polish ............................... yes
  403.     Portuguese Brazil .................... yes
  404.     Portuguese Portugal .................. yes
  405.     Romanian ............................. yes
  406.     Russian .............................. yes
  407.     Slovak ............................... yes
  408.     Slovenian ............................ yes
  409.     Albanian ............................. yes
  410.     Serbian .............................. yes
  411.     Swedish .............................. yes
  412.     Thai ................................. yes
  413.     Turkish .............................. yes
  414.     Ukrainian ............................ yes
  415.     Vietnamese ........................... yes
  416.     Simplified Chinese ................... yes
  417.     Traditional Chinese .................. yes
  418.     HongKong Chinese ..................... no
  419.   Traditional chinese input methods:
  420.     Zhuyin ............................... yes
  421.     Cangjie .............................. yes
  422. Note: Hunspell in Qt Virtual Keyboard is not enabled. Spelling correction will not be available.
  423. Note: Due to CMAKE_STAGING_PREFIX usage and an unfixed CMake bug,
  424.       to ensure correct build time rpaths, directory-level install
  425.       rules like ninja src/gui/install will not work.
  426.       Check QTBUG-102592 for further details.
  427. WARNING: QDoc will not be compiled, probably because libclang could not be located. This means that you cannot build the Qt documentation.
  428. Either set CMAKE_PREFIX_PATH or LLVM_INSTALL_DIR to the location of your llvm installation.
  429. On Linux systems, you may be able to install libclang by installing the libclang-dev or libclang-devel package, depending on your distribution.
  430. On macOS, you can use Homebrew's llvm package.
  431. You will also need to set the FEATURE_clang CMake variable to ON to re-evaluate this check.
  432. WARNING: Clang-based lupdate parser will not be available. LLVM and Clang C++ libraries have not been found.
  433. You will need to set the FEATURE_clangcpp CMake variable to ON to re-evaluate this check.
  434. WARNING: QtWebEngine won't be built. node.js version 12 or later is required.
  435. WARNING: QtPdf won't be built. node.js version 12 or later is required.
  436. root@zhengyang:/opt/qt6.5/qt-nanopibuild#
复制代码
   1.5.4 编译安装

  配置完成之后,就可以进行编译和安装了,约莫需要十几到几十分钟:
  1. root@zhengyang:/opt/qt6.5/qt-nanopibuild# cmake --build . --parallel -j4
  2. root@zhengyang:/opt/qt6.5/qt-nanopibuild# cmake --install .
复制代码
安装完成后,应该会在安装目次/opt/qt6.5/qt-nanopi下生成文件,然后实际测试发现被安装到了/opt/qt6.5/sysroot/opt/prefix/,因此我们拷贝一份过去;
  1. root@zhengyang:/opt/qt6.5/qt-nanopibuild# ls /opt/qt6.5/qt-nanopi
  2. root@zhengyang:/opt/qt6.5/qt-hostbuild# ls /opt/qt6.5/sysroot/opt/prefix/ -l
  3. drwxr-xr-x   2 root root  4096 Dec 17 16:00 bin
  4. drwxr-xr-x   4 root root  4096 Dec 17 16:00 doc
  5. drwxr-xr-x 130 root root  4096 Dec 17 16:00 include
  6. drwxr-xr-x   4 root root 28672 Dec 17 16:00 lib
  7. drwxr-xr-x   2 root root  4096 Dec 17 16:00 libexec
  8. drwxr-xr-x   2 root root 12288 Dec 17 16:00 metatypes
  9. drwxr-xr-x  64 root root  4096 Dec 17 16:00 mkspecs
  10. drwxr-xr-x   2 root root  4096 Dec 17 16:00 modules
  11. drwxr-xr-x   2 root root  4096 Dec 17 16:00 phrasebooks
  12. drwxr-xr-x  27 root root  4096 Dec 17 16:00 plugins
  13. drwxr-xr-x  25 root root  4096 Dec 17 16:00 qml
  14. drwxr-xr-x   2 root root 12288 Dec 17 16:00 translations
  15. root@zhengyang:/opt/qt6.5/qt-hostbuild# cp -ar /opt/qt6.5/sysroot/opt/prefix/* /opt/qt6.5/qt-nanopi
复制代码
(1) 如果使用了libxkbcommon 1.6.0及更高版本,编译过程可能出现如下错误:
  1. /opt/qt6.5/qt-everywhere-src-6.5.0/qtbase/src/gui/platform/unix/qxkbcommon.cpp:242:16: error: ‘XKB_KEY_dead_lowline’ was not declared in this scope; did you mean ‘XKB_KEY_dead_belowring’?
  2.   242 |         Xkb2Qt<XKB_KEY_dead_lowline,            Qt::Key_Dead_Lowline>,
  3.       |                ^~~~~~~~~~~~~~~~~~~~
  4.       |                XKB_KEY_dead_belowring
  5. /opt/qt6.5/qt-everywhere-src-6.5.0/qtbase/src/gui/platform/unix/qxkbcommon.cpp:242:69: error: template argument 1 is invalid
  6.   242 |         Xkb2Qt<XKB_KEY_dead_lowline,            Qt::Key_Dead_Lowline>,
  7.       |                                                                     ^
复制代码
修改src/gui/platform/unix/qxkbcommon.cpp文件:
  

  修改后的代码如下:
  1. /* The following four XKB_KEY_dead keys got removed in libxkbcommon 1.6.0
  2.    The define check is kind of version check here. */
  3. #ifdef XKB_KEY_dead_lowline
  4.         Xkb2Qt<XKB_KEY_dead_lowline,            Qt::Key_Dead_Lowline>,
  5.         Xkb2Qt<XKB_KEY_dead_aboveverticalline,  Qt::Key_Dead_Aboveverticalline>,
  6.         Xkb2Qt<XKB_KEY_dead_belowverticalline,  Qt::Key_Dead_Belowverticalline>,
  7.         Xkb2Qt<XKB_KEY_dead_longsolidusoverlay, Qt::Key_Dead_Longsolidusoverlay>,
  8. #endif
复制代码
(2) 如果编译过程出现GLIBC相关错误,比如:
  1. /usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/bin/ld: /opt/qt6.5/sysroot/lib/aarch64-linux-gnu/libglib-2.0.so.0: undefined reference to `pthread_rwlock_destroy@GLIBC_2.34'
  2. /usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/bin/ld: /opt/qt6.5/sysroot/lib/aarch64-linux-gnu/libglib-2.0.so.0: undefined reference to `pthread_key_create@GLIBC_2.34'
  3. /usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/bin/ld: qtbase/lib/libQt6Core.so.6.5.0: undefined reference to `dlopen@GLIBC_2.17'
  4. collect2: error: ld returned 1 exit status
  5. [3237/8385] Building CXX object qtdeclarative/tools/qmlls/CMakeFiles/qmlls.dir/qmlcompletionsupport.cpp.o
  6. ninja: build stopped: subcommand failed.
复制代码
出现这种题目就是因为“编译库的编译器” 和 “编译当前程序的编译器” 版本是不一样的,具体一点就是因为,当前程序的编译器的版本是比较低的,只要升级一下就可以了。
  检察/opt/qt6.5/sysroot/lib/aarch64-linux-gnu/libglib-2.0.so.0依靠的glibc版本:
  1. pi@NanoPC-T6:/opt/qt6.5$ ldd /opt/qt6.5/sysroot/lib/aarch64-linux-gnu/libglib-2.0.so.0.7800.3   # libglib-2.0.so指向这个文件
  2.         linux-vdso.so.1 (0x0000007f9fc99000)
  3.         libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000007f9fa30000)
  4.         libpcre2-8.so.0 => /lib/aarch64-linux-gnu/libpcre2-8.so.0 (0x0000007f9f990000)
  5.         libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000007f9f7e0000)
  6.         /lib/ld-linux-aarch64.so.1 (0x0000007f9fc5c000)
  7.         libpthread.so.0 => /lib/aarch64-linux-gnu/libpthread.so.0 (0x0000007f9f7b0000)
  8. pi@NanoPC-T6:/opt/qt6.5$ objdump -p /opt/qt6.5/sysroot/lib/aarch64-linux-gnu/libglib-2.0.so.0.7800.3 | grep GLIBC_
  9.     0x06969197 0x00 05 GLIBC_2.17
  10.     0x06969188 0x00 07 GLIBC_2.28
  11.     0x069691b3 0x00 06 GLIBC_2.33  # 依赖2.33版本
  12.     0x069691b2 0x00 04 GLIBC_2.32
  13.     0x069691b4 0x00 03 GLIBC_2.34  # 依赖2.34版本
  14.     0x06969197 0x00 02 GLIBC_2.17
复制代码
因此需要为交织编译工具aarch64-linux-gnu升级glibc版本;起首检察glibc支持的版本,可以看到其的确不支持2.34版本;
  1. root@zhengyang:/opt# strings /usr/aarch64-linux-gnu/lib/libc.so.6 | grep GLIBC_
  2. GLIBC_2.17
  3. GLIBC_2.18
  4. GLIBC_2.22
  5. GLIBC_2.23
  6. GLIBC_2.24
  7. GLIBC_2.25
  8. GLIBC_2.26
  9. GLIBC_2.27
  10. GLIBC_2.28
  11. GLIBC_2.29
  12. GLIBC_2.30
  13. GLIBC_PRIVATE
复制代码
这里我们通过对glibc源码进行交织编译得到高版本的glibc,这里选择一个大于2.34的版本;
  1. # 下载软件包
  2. root@zhengyang:/opt# wget https://mirrors.aliyun.com/gnu/glibc/glibc-2.36.tar.gz
  3. # 解压
  4. root@zhengyang:/opt# tar -zxvf glibc-2.36.tar.gz
  5. root@zhengyang:/opt# cd glibc-2.36
  6. # 预编译
  7. root@zhengyang:/opt/glibc-2.36# mkdir build
  8. root@zhengyang:/opt/glibc-2.36# cd build
  9. root@zhengyang:/opt/glibc-2.36/build# apt install gawk
  10. root@zhengyang:/opt/glibc-2.36/build# apt install bison
  11. root@zhengyang:/opt/glibc-2.36/build# export LD_LIBRARY_PATH=
  12. root@zhengyang:/opt/glibc-2.36/build# CC=/usr/bin/aarch64-linux-gnu-gcc ../configure --prefix=/usr/aarch64-linux-gnu --build=x86_64-linux-gnu --host=aarch64-linux-gnu --target=aarch64-linux-gnu --with-headers=/usr/aarch64-linux-gnu/include --disable-multilib libc_cv_forced_unwind=yes LDFLAGS="-L/usr/aarch64-linux-gnu/lib"  --disable-werror
  13. # 编译
  14. root@zhengyang:/opt/glibc-2.36/build# make -j4
  15. root@zhengyang:/opt/glibc-2.36/build# make install
  16. root@zhengyang:/opt/glibc-2.36/build# ll /usr/aarch64-linux-gnu
  17. drwxr-xr-x  2 root root 4096 Dec 17 23:20 bin/
  18. drwxr-xr-x  2 root root 4096 Dec 17 23:20 etc/
  19. drwxr-xr-x 34 root root 4096 Dec 17 23:20 include/
  20. drwxr-xr-x  4 root root 4096 Dec 17 23:20 lib/
  21. drwxr-xr-x  3 root root 4096 Dec 17 23:19 libexec/
  22. drwxr-xr-x  2 root root 4096 Dec 17 23:20 sbin/
  23. drwxr-xr-x  5 root root 4096 Dec 17 23:20 share/
  24. drwxr-xr-x  3 root root 4096 Dec 17 23:20 var/
复制代码
再次检察glibc支持的版本:
  1. root@zhengyang:/opt/glibc-2.36/build# strings /usr/aarch64-linux-gnu/lib/libc.so.6 | grep GLIBC_2.
  2. GLIBC_2.17
  3. GLIBC_2.18
  4. GLIBC_2.22
  5. GLIBC_2.23
  6. GLIBC_2.24
  7. GLIBC_2.25
  8. GLIBC_2.26
  9. GLIBC_2.27
  10. GLIBC_2.28
  11. GLIBC_2.29
  12. GLIBC_2.30
  13. GLIBC_2.31
  14. GLIBC_2.32
  15. GLIBC_2.33  # 新增
  16. GLIBC_2.34  # 新增
  17. GLIBC_2.35  # 新增
  18. GLIBC_2.36  # 新增
复制代码
参考文章:
  

  • version GLIBC_2.29 not found 的缘故原由和怎么解决题目;
  • getting fatal error: asm/prctl.h: No such file or directory。
  1.5.5 同步文件到开辟板

  同步文件到开辟板(这是使用rsync):
  1. root@zhengyang:/opt# rsync -avz --rsync-path="sudo rsync" /opt/qt6.5/sysroot/opt/prefix/* pi@192.168.0.101:/opt/qt6.5 # 宿主机运行
  2. pi@NanoPC-T6:~$ ls /opt/qt6.5/ -l  # 开发板运行
  3. drwxr-xr-x   2 root root  4096 12月 17 16:00 bin
  4. -rwxr-xr-x   1 root root   343 12月 17 14:40 build_sysroot.sh
  5. drwxr-xr-x   4 root root  4096 12月 17 16:00 doc
  6. drwxr-xr-x 130 root root  4096 12月 17 16:00 include
  7. drwxr-xr-x   4 root root 24576 12月 17 16:00 lib
  8. drwxr-xr-x   2 root root  4096 12月 17 16:00 libexec
  9. drwxr-xr-x   2 root root 12288 12月 17 16:00 metatypes
  10. drwxr-xr-x  64 root root  4096 12月 17 16:00 mkspecs
  11. drwxr-xr-x   2 root root  4096 12月 17 16:00 modules
  12. drwxr-xr-x   2 root root  4096 12月 17 16:00 phrasebooks
  13. drwxr-xr-x  27 root root  4096 12月 17 16:00 plugins
  14. drwxr-xr-x  25 root root  4096 12月 17 16:00 qml
  15. drwxr-xr-x   5 root root  4096 12月 17 14:40 sysroot
  16. drwxr-xr-x   2 root root 12288 12月 17 16:00 translations
复制代码
当然也可以使用scp下令:
  1. root@zhengyang:/opt# scp -r /opt/qt6.5/sysroot/opt/prefix/* pi@192.168.0.101:/opt/qt6.5
复制代码
1.5.6 配置环境变量

  设置 LD_LIBRARY_PATH 环境变量,将 `/opt/qt6.5/lib 目次添加到了动态链接库搜索路径中;
  设置QT_QPA_PLATFORM_PLUGIN_PATH环境变量,将将 /opt/qt6.5/plugins 目次添加到了插件搜索路径中;
  1. pi@NanoPC-T6:/opt# sudo vim /etc/profile
  2. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/qt6.5/lib
  3. export QT_QPA_PLATFORM_PLUGIN_PATH=$QT_QPA_PLATFORM_PLUGIN_PATH:/opt/qt6.5/plugins
  4. pi@NanoPC-T6:/opt$ source /etc/profile
  5. pi@NanoPC-T6:/opt# echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/qt6.5/lib" >> ~/.bashrc
  6. pi@NanoPC-T6:/opt# echo "export QT_QPA_PLATFORM_PLUGIN_PATH=$QT_QPA_PLATFORM_PLUGIN_PATH:/opt/qt6.5/plugins" >> ~/.bashrc
  7. pi@NanoPC-T6:/opt# source ~/.bashrc
  8. pi@NanoPC-T6:/opt# su root
  9. root@NanoPC-T6:/opt# echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/qt6.5/lib" >> ~/.bashrc
  10. root@NanoPC-T6:/opt# echo "export QT_QPA_PLATFORM_PLUGIN_PATH=$QT_QPA_PLATFORM_PLUGIN_PATH:/opt/qt6.5/plugins" >> ~/.bashrc
  11. root@NanoPC-T6:/opt# source ~/.bashrc
复制代码
这里有须要说一下/etc/profile和~/.bashrc区别,/etc/profile和~/.bashrc都是用于定义环境变量和实行初始化下令的文件,不同之处在于它们的作用范围和实行时机;
  

  • /etc/profile是体系级别的配置文件,适用于全部用户。当用户登录时,体系会主动读取该文件中定义的环境变量和初始化下令,并将其应用于整个体系。因此,如果您盼望在全部用户之间共享环境变量或实行初始化下令,可以将它们添加到/etc/profile中;
  • ~/.bashrc是用户级别的配置文件,只适用于当前用户。当用户登录后,体系会主动读取该文件并将此中定义的环境变量和初始化下令应用于该用户的bash shell。因此,如果您只需要在当前用户的bash shell中定义环境变量或实行初始化下令,可以将它们添加到~/.bashrc中;
  这里为啥配置了/etc/profile还配置了~/.bashrc,主要是因为我在测试的时候发现,如果只配置/etc/profile,在debian桌面终端(非SSH毗连终端)运行Qt程序的时候,LD_LIBRARY_PATH环境变量并没有生效,而配置了用户级的~/.bashrc会生效。
  1.6 安装Qt Creator

  1.6.1 下载安装包

  下载Qt Creator 11.0到ubuntu中:
  1. root@zhengyang:/opt#  wget https://download.qt.io/official_releases/qtcreator/11.0/11.0.0/qt-creator-opensource-linux-x86_64-11.0.0.run
  2. # 安装依赖库
  3. root@zhengyang:/opt# sudo apt install --assume-yes xfce4 xorg-dev libopencc2 libopencc2-data unzip zip  # 选择gdm3
  4. root@zhengyang:/opt# sudo apt install --reinstall libxcb-xinerama0
复制代码
1.6.2 修改权限并安装

  需要在ubuntu桌面环境,打开终端运行:
  1. zhengyang@zhengyang:~/桌面$ cd /opt
  2. zhengyang@zhengyang:/opt# sudo chmod 777 qt-creator-opensource-linux-x86_64-11.0.0.run
  3. zhengyang@zhengyang:/opt# sudo ./qt-creator-opensource-linux-x86_64-11.0.0.run
复制代码
之后就会弹窗,需要我们登录下,没有账号就去Qt官网注册一个:
     
    安装过程基本上一起 Next 下去,此中:
  

  • 选择安装目次,配置为/opt/qtcreator-11.0.0;
  • 选择组件:全部勾选;
  一直下一步,直到安装完成。安装完成后,打开Qt Creator的开辟界面:
     
    1.6.3 检察安装路径

  1. root@zhengyang:/opt# cd qtcreator-11.0.0/
  2. root@zhengyang:/opt/qtcreator-11.0.0# ll
  3. drwxr-xr-x 2 root root     4096 Nov 22 16:09 bin/
  4. -rw-r--r-- 1 root root     3540 Dec 17 17:11 components.xml
  5. -rw-r--r-- 1 root root     6685 Dec 17 17:11 InstallationLog.txt
  6. -rw-r--r-- 1 root root       48 Dec 17 17:11 installer.dat
  7. drwxr-xr-x 5 root root     4096 Dec 17 17:11 installerResources/
  8. drwxr-xr-x 6 root root     4096 Nov 22 16:09 lib/
  9. drwxr-xr-x 3 root root     4096 Nov 22 16:09 libexec/
  10. -rw-r--r-- 1 root root      725 Dec 17 17:11 licenseInfo.txt
  11. drwxr-xr-x 2 root root     4096 Dec 17 17:11 Licenses/
  12. -rw-r--r-- 1 root root      472 Dec 17 17:11 network.xml
  13. -rwxr-xr-x 1 root root 43893816 Dec 17 17:11 QtCreatorUninstaller*
  14. -rw-r--r-- 1 root root   360709 Dec 17 17:11 QtCreatorUninstaller.dat
  15. -rw-r--r-- 1 root root     6123 Dec 17 17:11 QtCreatorUninstaller.ini
  16. drwxr-xr-x 6 root root     4096 Dec 17 17:11 share/
  17. drwxr-xr-x 3 root root     4096 Nov 22 21:40 Tools/
  18. root@zhengyang:/opt/qtcreator-11.0.0# ls bin
  19. qbs  qbs-config  qbs-config-ui  qbs-create-project  qbs-setup-android  qbs-setup-qt  qbs-setup-toolchains  qt.conf  qtcreator  qtcreator.sh
复制代码
1.7 简单示例

  在宿主机打开Qt Creator,点击【工具】-【外部】- 【配置】,进入配置页面。
  1. zhengyang@zhengyang:/$ sudo /opt/qtcreator-11.0.0/bin/qtcreator
复制代码
1.7.1 编译器

  点击左侧【构建套件】,选择【编译器】,这里已经检测到我们的交织编译器(aarch64-linux-gnu-gcc和aarch64-linux-gnu-g++);如果没有,请添加一个GCC 编译器并定位编译器的位置。然后点击“应用”。
     
    1.7.2 Qt版本

  点击左侧【Qt版本】,手动添加:
  

  qt-hot用于为宿主机编译Qt应用程序;
  qt-nanopi用于为开辟板编译Qt应用程序。
  1.7.3 添加设备

  我们还需要设置Qt Creator中的设备。在【选项】菜单中,选择侧边栏中的【设备】;
  (1)在【设备】选项卡下,选择【添加】。在设备配置领导中,选择Remote Linux Device,然后点击开始领导;
     
    指定一个可识别的名称、您用于SSH的开辟板IP地点和用户名;
  

  体系会提示您将公钥部署到目的设备上。这将加快部署过程,因为每次Qt Creator尝试向目的发送文件时,您不需要输入密码。
  点击下一步,然后点击完成。Qt Creator将在完成后测试毗连,并告诉您是否可以创建与目的设备的毗连。
     
    (2)上面配置完成后,就可以正常部署运行,每次ssh毗连都需要输入密码,接下来讲下使用密钥登录, 打开Qt Creator,依次点击 【工具】- 【外部】 - 【配置】 -【设备】,就可以看到前面配置的ssh登录设备:
     
    步调如下:
  

  • 如果没有密钥对,先点击生成密钥:
  

  

  • 保存的密钥对默认在用户目次~/.ssh下,然后点击部署密钥,选择前面生成的公钥,输入开辟板debain的用户密码即可完成部署。 大概本身复制公钥到开辟板上,然后下令:
    1. cat qtc_id.pub >> ~/.ssh/authorized_keys
    2. # 如果没有authorized_keys,使用命令创建一个:
    3. touch authorized_keys
    复制代码
  • 部署密钥之后,验证类型点击使用 Specific key,之后就可以使用密钥直接远程毗连;
  1.7.4 安装调试器

  在宿主机ubuntu体系,先使用下令安装gdb工具:
  1. root@zhengyang:/opt/# sudo apt install -y  gdb-multiarch
  2. root@zhengyang:/opt# which gdb-multiarch
  3. /usr/bin/gdb-multiarch
复制代码
开辟板一般默认已经安装gdb工具,如果没有可以使用下令安装下:
  1. pi@NanoPC-T6:/opt/qt-project$  sudo aptitude install -y gdbserver
  2. pi@NanoPC-T6:/opt/qt-project$ which gdbserver
  3. /usr/bin/gdbserver
复制代码
在Qt Creator配置页面,点击左侧【构建套件】,选择【Debuggers】,单击新增:
     
    添加路径/usr/bin/gdb-multiarch,保存应用。
  1.7.5 定义构建套件

  (1) ubuntu_rk3588_debian11_qt6编译套件
  设置完全部须要的组件后,接下来我们添加一个编译套件( ubuntu_rk3588_debian11_qt6 ),用来搭建一个交织编译环境,为开辟板编译Qt程序;
     
    然后配置使用我们之前安装的cmake(注意使用3.16版本以上),配置cmake generator使用makefile(也可以使用ninja等)。
  而且要修改下cmake的配置,这里添加配置文件qt.toolchain.cmake路径:
  1. -DCMAKE_TOOLCHAIN_FILE:FILEPATH=/opt/qt6.5/qt-nanopi/lib/cmake/Qt6/qt.toolchain.cmake
复制代码
(2) 桌面套件,用于为宿主机ubuntu体系开辟Qt程序;
     
    1.7.6 创建项目

  在Qt Creator首页点击【创建项目】 ;
     
    选中【Application(Qt)】- 【Qt Widgets Application】;
  (1) Location:指定项目名称以及保存路径,然后点击【下一步】;
     
    (2) 构建体系选择cmake,然后点击【下一步】;
  (3) Details点击【下一步】;
  (4) Tranlation语言选择Chinese(China),然后点击【下一步】;
  (5) 构建套件,全选;
  

  (6) 汇总:点击【完成】;
  

  1.8 本地运行测试

  1.8.1 运行效果

  点击左侧【项目】,选中【桌面】下【构建】按钮,单后点击左下角的【运行】按钮:
     
    可以看到该Qt程序可以在宿主机ubuntu体系正常运行。
  1.8.2 XCB错误处理

  如果运行时出现找不到插件XCB错误:
  1. 19:06:11: Starting /opt/qt-project/build-demo1-unknown-Debug/demo1...
  2. qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
  3. This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
  4. Available platform plugins are: vkkhrdisplay, minimal, minimalegl, eglfs, linuxfb, vnc, offscreen.
复制代码
开启Debug模式,在项目中添加环境变量;左侧【项目】 – 【桌面】 – 【构建】 – 【构建设置】– 【Build Environment】;
  1. export QT_DEBUG_PLUGINS=1
复制代码
   
    可以看到,搜索的是Qt源码编译的安装路径,该路径下没有libqxcb.so;
  1. root@zhengyang:/opt# ll /opt/qt6.5/qt-host/plugins/platforms
  2. -rw-r--r--  1 root root  35280 Dec 17 18:24 libqeglfs.so
  3. -rw-r--r--  1 root root 360192 Dec 17 18:25 libqlinuxfb.so
  4. -rw-r--r--  1 root root  79176 Dec 17 18:24 libqminimalegl.so
  5. -rw-r--r--  1 root root  68408 Dec 17 18:24 libqminimal.so
  6. -rw-r--r--  1 root root 159304 Dec 17 18:24 libqoffscreen.so
  7. -rw-r--r--  1 root root 314464 Dec 17 18:25 libqvkkhrdisplay.so
  8. -rw-r--r--  1 root root 192232 Dec 17 18:25 libqvnc.so
复制代码
在编译宿主机Qt6编译配置时指定,然后重新编译配置以及源码;
  1. -DQT_FEATURE_xcb=ON -DFEATURE_xcb_xlib=ON -DQT_FEATURE_xlib=ON
复制代码
1.9 远程机器运行测试

  1.9.1 远程部署错误

  点击左侧【项目】,选中【ubuntu_rk3588_debian11_qt6】下【构建】按钮,接着点击左下角的【运行】图标按钮,错误信息如下:
  1. 20:27:24: 为项目demo1执行步骤 ...
  2. 20:27:24: 正在启动 "/opt/cmake/bin/cmake" --build /opt/qt-project/build-demo1-ubuntu_rk3588_debian11_qt6-Debug --target all install
  3. [ 20%] Automatic MOC and UIC for target demo1
  4. [ 20%] Built target demo1_autogen
  5. [100%] Built target demo1
  6. Install the project...
  7. -- Install configuration: "Debug"
  8. -- Up-to-date: /tmp/QtCreator-dLvOjN/staging-ccdd2a4bbb6f2446/usr/local/bin/demo1
  9. 20:27:24: 进程"/opt/cmake/bin/cmake"正常退出。
  10. 20:27:24: Trying to kill "/usr/local/bin/demo1" on remote device...
  11. 20:27:24: Remote application killed.
  12. 20:27:24: 部署步骤完成。
  13. sending incremental file list
  14. demo1
  15. sent 1,146,921 bytes  received 35 bytes  2,293,912.00 bytes/sec
  16. total size is 1,146,568  speedup is 1.00
  17. 20:27:25: rsync failed with exit code 23.
  18. rsync: [receiver] mkstemp "/usr/local/bin/.demo1.cOVHCN" failed: Permission denied (13)
  19. rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1205) [sender=3.1.3]
  20. 20:27:25: 部署步骤失败。
  21. Error while building/deploying project demo1 (kit: ubuntu_rk3588_debian11_qt6)
  22. When executing step "Deploy files via rsync"
  23. 20:27:25: Elapsed time: 00:01.
复制代码
可以看到在使用rsync进行文件同步的时候失败了,主要是因为配置的开辟板debain体系的pi用户没有创建文件的权限。
  因此配置开辟板可以通过root用户登录,利用vim打开并修改/etc/ssh/sshd_config文件:
  1. pi@NanoPC-T6:/$ sudo vim /etc/ssh/sshd_config
  2. PermitRootLogin yes
  3. #重新启动SSH服务器
  4. pi@NanoPC-T6:/$ sudo /etc/init.d/ssh restart
复制代码
然后通过Qt Creator打开【工具】—【外部】—【配置】—【设备】,删除设备重新创建,用户设置为root。
  注意:这里我们也可以点击【ubuntu_rk3588_debian11_qt6】下【运行】按钮,通过右侧【运行配置】中的部署来调整文件同步策略。
  1.9.2 测试环境变量

  起首确保开辟板配置的环境变量LD_LIBRARY_PATH、QT_QPA_PLATFORM_PLUGIN_PATH没有题目;在桌面终端和SSH终端均运行如下下令测试:
  1. pi@NanoPC-T6:/$ echo $LD_LIBRARY_PATH
  2. :/opt/qt6.5/lib:/opt/qt6.5/lib
  3. pi@NanoPC-T6:/$ echo $QT_QPA_PLATFORM_PLUGIN_PATH
  4. :/opt/qt6.5/plugins:/opt/qt6.5/plugins:/opt/qt6.5/plugins
复制代码
1.9.3 QPA插件

  这块内容涉及到linux图像显示的内容,保举先去阅读这篇文章:《Linux图形显示》。
  在开辟板上运行Qt程序,通过QPA(Qt Platform Abstraction)平台抽象显示,不同平台显示可以使用不同QPA插件, 一般Qt将根据平台选择一个默认的QPA插件, 也可以设置QT_QPA_PLATFORM环境变量大概-platform下令行参数选择不同的平台插件。
  在嵌入式Linux体系上,可以使用多个平台插件:EGLFS,LinuxFB,DirectFB 或Wayland、XCB。但是,这些插件的可用性取决于 Qt的配置方式。
  我们在交织编译Qt时已经配置了:
  1. Qt Gui:
  2.   Accessibility .......................... yes
  3.   FreeType ............................... yes
  4.     Using system FreeType ................ yes
  5.   HarfBuzz ............................... yes
  6.     Using system HarfBuzz ................ yes
  7.   Fontconfig ............................. yes
  8.   Image formats:
  9.     GIF .................................. yes
  10.     ICO .................................. yes
  11.     JPEG ................................. yes
  12.       Using system libjpeg ............... yes
  13.     PNG .................................. yes
  14.       Using system libpng ................ yes
  15.   Text formats:
  16.     HtmlParser ........................... yes
  17.     CssParser ............................ yes
  18.     OdfWriter ............................ yes
  19.     MarkdownReader ....................... yes
  20.       Using system libmd4c ............... no
  21.     MarkdownWriter ....................... yes
  22.   EGL .................................... yes  # 需要配置为yes
  23.   OpenVG ................................. no
  24.   OpenGL:                                       
  25.     opengl_desktop ....................... no
  26.     OpenGL ES 2.0 ........................ yes # 需要配置为yes
  27.     opengles3 ............................ yes # 需要配置为yes
  28.     OpenGL ES 3.1 ........................ yes # 需要配置为yes
  29.     OpenGL ES 3.2 ........................ yes # 需要配置为yes
  30.   Vulkan ................................. no
  31.   Session Management ..................... yes
  32. Features used by QPA backends:                  
  33.   evdev .................................. yes   # 需要配置为yes
  34.   libinput ............................... yes   # 需要配置为yes
  35.   HiRes wheel support in libinput ........ no   
  36.   INTEGRITY HID .......................... no   
  37.   mtdev .................................. yes   # 需要配置为yes
  38.   tslib .................................. yes   # 需要配置为yes
  39.   xkbcommon .............................. yes   # 需要配置为yes
  40.   X11 specific:                                  # 下面的要必须都是yes
  41.     xlib ................................. yes
  42.     XCB Xlib ............................. yes
  43.     EGL on X11 ........................... yes
  44.     xkbcommon-x11 ........................ yes
  45.     xcb-sm ............................... yes
  46. QPA backends:
  47.   DirectFB ............................... no
  48.   EGLFS .................................. yes    # 需要配置为yes
  49.   EGLFS details:
  50.     EGLFS OpenWFD ........................ no
  51.     EGLFS i.Mx6 .......................... no
  52.     EGLFS i.Mx6 Wayland .................. no
  53.     EGLFS RCAR ........................... no
  54.     EGLFS EGLDevice ...................... yes     # 需要配置为yes
  55.     EGLFS GBM ............................ yes     # 需要配置为yes
  56.     EGLFS VSP2 ........................... no
  57.     EGLFS Mali ........................... yes     # 需要配置为yes
  58.     EGLFS Raspberry Pi ................... no
  59.     EGLFS X11 ............................ yes     # 需要配置为yes
  60.   LinuxFB ................................ yes     # 需要配置为yes
  61.   VNC .................................... yes
  62.   VK_KHR_display ......................... no
  63.   QNX:
  64.     lgmon ................................ no
  65.     IMF .................................. no
  66.   XCB:
  67.     Using system-provided xcb-xinput ..... no
  68.     GL integrations:                           # 下面的要必须都是yes
  69.       GLX Plugin ......................... yes
  70.         XCB GLX .......................... yes
  71.       EGL-X11 Plugin ..................... yes
  72.   Windows:
  73.     Direct 2D ............................ no
  74.     Direct 2D 1.1 ........................ no
  75.     DirectWrite .......................... no
  76.     DirectWrite 3 ........................ no
复制代码
QPA可以通过使用以下环境变量进行配置:
  环境变量描述QT_QPA_PLATFORM指定平台插件,比如eglfs、xcb、linuxfb(如果指定fb设备,可以设置为linuxfb:fb=/dev/fb0)QT_QPA_FONTDIR字体库路径QT_QPA_PLATFORM_PLUGIN_PATH设置插件路径,比如/opt/qt6.5/pluginsQWS_MOUSE_PROTO触摸屏输入设备,比如/dev/input/event0QT_QPA_GENERIC_PLUGINS插件,比如
触摸库tslib
鼠标插件,evdevmouse:/dev/input/event
键盘插件,evdevkeyboard:/dev/input/eventQT_QPA_EVDEV_KEYBOARD_PARAMETERS键盘设备QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS触摸配置  1.9.4 LinuxFB

  该插件通过Linux的fbdev子体系直接写入帧缓冲区。仅支持软件渲染的内容。请注意,在某些设置下,显示性能可能会受到限定。
  由于fbdev在Linux内核中已被弃用,因此从Qt 5.9开始,还提供了DRM支持。要使用它,请将QT_QPA_FB_DRM环境变量设置为非零值。设置后,只要体系支持DRM,/dev/fb0就不会访问旧式帧缓存设备。取而代之的是,通过DRM API来设置呈现,类似于eglfs_kms EGLFS中的后端。输出颠末双缓冲和页面翻转,也为软件渲染的内容提供了适当的垂直同步。
     
    该插件显示会全屏输出,设置QT_QPA_FB_FORCE_FULLSCREEN环境变量设置为0,将非全屏显示。
  (1) LinuxFB可以通过使用以下环境变量进行配置:
  环境变量描述QT_QPA_FB_DRM使用DRM,设置为1QT_QPA_FB_FORCE_FULLSCREEN是否全屏显示,设置为0,将非全屏显示QT_QPA_FB_HIDECURSOR显示大概隐藏鼠标QT_QPA_FB_DISABLE_INPUTLinuxFB禁用输入,即不使用libinput  更多配置参考:https://doc.qt.io/qt-5/embedded-linux.html#linuxfb。
  (2) 起首进行环境变量配置:
  1. pi@NanoPC-T6:/opt# sudo vim /etc/profile
  2. export QT_QPA_FB_DRM=1
  3. export QT_QPA_FB_FORCE_FULLSCREEN=0
  4. pi@NanoPC-T6:/opt$ source /etc/profile
复制代码
接着Qt Creator具体配置如下:
  

  • 点击左侧【项目】 — 【ubuntu_rk3588_debian11_qt6】 — 【构建】;
  • 右侧【运行配置】 — 【运行】 — 【Command line arguments】输入: -platform linuxfb;指定Qt以linuxfb的方式显示,输出设备默以为/dev/fb0;
  点击左侧【运行】图标,运行程序,测试发现这个在开辟板毗连的显示屏上全屏显示,但是我设置的是非全屏显示啊,阐明我们在/etc/profile中配置的环境变量并没有生效。
     
    从控制台的启动日记看到,实际上就是在开辟板上实行了如下下令:
  1. /usr/local/bin/demo1 -platform linuxfb
复制代码
因此,我尝试在开辟板终端实行了这个下令,发现Qt程序可以正常运行,而且非全屏显示。
  1.9.5 EGLFS

  EGLFS是一个为了Qt5应用运行的平台插件,EGLFS是Qt本身实现的一个GUI显示插件,可以在EGL和OpenGL ES之上运行Qt应用程序,而不需要真实的视窗体系(比如X11、Wayland)。 EGLFS还支持软件渲染窗口,如QWidget的内容使用CPU渲染成图像,然后上传到纹理中,并由插件进行合成;
  对于包含GPU的现代嵌入式Linux设备,保举使用EGLFS插件。 EGLFS逼迫第一个顶级窗口(QWidget大概QQucikView)为全屏。这个窗口也是根Widget窗口,其它的顶级窗口(例如对话框)都是这个根窗口的子窗口。
  (1) Rk3588系列使用Mali-G610,支持OpenGL ES1.1, 2.0 and 3.2, OpenGL 2.2, Vulkan 1.2 etc以及OpenCL 1.1, 1.2, 2.0。
  Mali GPU驱动一般分为两部分:
  

  • 一小部分在linux内核中;
  • 另外一大部分在userspace,在userspace的部分向下操作内核中的驱动,向上对应用层提供标准的OpenGL接口,这样各种图形显示相关的应用才气通过标准的OpenGL API进行图形渲染加速;
     
    在Linux体系上使用OpenGL ES大概OpenCL接口,需要添加libmali库以及头文件, libmali有不同的版本(X11,GDM,Wayland),提供了opengles,egl,opencl接口。
  除了GPU,RK系列板卡上还有一个独立的2D硬件加速器–RGA (Raster Graphic Acceleration Unit),可以不占用CPU资源下, 加速点/线绘制,实行图像缩放、旋转、bitBlt、alpha混合等常见的2D图形操作,用户空间使用通过librga 库。
  (2) EGLFS可以通过使用以下环境变量进行配置:
  环境变量描述QT_QPA_EGLFS_FB覆盖帧缓冲设备。默认值为/dev/fb0。在大多数嵌入式平台上,此变量不太告急,因为帧缓冲区仅用于查询显示尺寸等设置。但是,在某些设备上,此变量提供了指定在多个显示设置中使用哪个显示器的功能,类似于LinuxFB 中的fb参数。QT_QPA_EGLFS_WIDTH和QT_QPA_EGLFS_HEIGHT包含屏幕的宽度和高度(以像素为单位)。虽然EGLFS尝试从帧缓冲设备/dev/fb0确定尺寸,但这并不总是有效。可能需要手动指定尺寸。QT_QPA_EGLFS_PHYSICAL_WIDTH和QT_QPA_EGLFS_PHYSICAL_HEIGHT指定物理屏幕的宽度和高度(以毫米为单位)。有些平台没有/dev/fb0大概查询失败的情况,这些值使用默认的DPI=100盘算宽和高。QT_QPA_EGLFS_DEPTH覆盖屏幕的颜色深度。在帧缓冲设备/dev/fb0不可用或查询不成功的平台上,使用默认值32。注意:此变量仅影响QScreen的色深值。它与EGL配置和OpenGL 渲染所使用的颜色深度无关。QT_QPA_EGLFS_SWAPINTERVAL默认的交换值为1。这将会同步垂直刷新。例如,设置隔断为0,将会尽最快的方式运行不带任何同步。QT_QPA_EGLFS_DEBUG设置后,一些调试信息会打印在调试输出上。QT_QPA_EGLFS_INTEGRATION除了编译进的hooks,可以或许提供设备大概厂商修改的可动态加载的插件。该环境变量指定一个特定的插件。
设置为eglfs_kms将使用KMS/DRM后端。QT_QPA_EGLFS_KMS_ATOMIC默认情况下,KMS后端将使用旧版API,可以启用DRM atomic API,通过将QT_QPA_EGLFS_KMS_ATOMIC环境变量设置为1QT_QPA_EGLFS_KMS_CONFIGKMS/DRM后端还通过JSON文件支持自定义配置QT_QPA_EGLFS_ALWAYS_SET_MODE指定将current选择一种分辨率与当前模式匹配的模式,QT_QPA_EGLFS_ALWAYS_SET_MODEQT_QPA_EGLFS_TSLIB启用tslib支持QT_QPA_EGLFS_HIDECURSOR显示大概隐藏鼠标QT_QPA_EGLFS_ROTATION界面旋转角度 0,90,180,270,(使用触摸屏幕,触摸也要旋转)QT_QPA_EGLFS_DISABLE_INPUTEGLFS禁用输入,即不使用libinput  更多配置参考:https://doc.qt.io/qt-5/embedded-linux.html#display-outpu。
  (3) 起首进行环境变量配置:
  1. pi@NanoPC-T6:/opt# sudo vim /etc/profile
  2. export QT_QPA_EGLFS_INTEGRATION=eglfs_kms
  3. pi@NanoPC-T6:/opt$ source /etc/profile
复制代码
接着Qt Creator具体配置如下:
  

  • 点击左侧【项目】 — 【ubuntu_rk3588_debian11_qt6】 — 【构建】;
  • 右侧【运行配置】 — 【运行】 — 【Command line arguments】输入: -platform eglfs;
  点击左侧【运行】图标,运行程序,运行完之后发现Qt应用程序在开辟板毗连的显示屏全屏显示了。
  我们可以尝试在开辟板终端运行如下下令,发现Qt应用程序也是全屏显示。
  1. /usr/local/bin/demo1 -platform eglfs
复制代码
1.9.6 XCB

  Qt程序也可以通过桌面窗口体系运行显示。 XCB是桌面Linux平台上使用的X11插件,使用窗口体系显示Qt程序。
  (1) XCB是Xlib的替换方案,提供了更简单、更灵活的API,可以资助开辟职员更轻松地创建X应用程序;
  

  • Xlib 大概X库是X协议的的一个简单的封装,Gtk+、Qt等使用该库来创建软件应用程序的图形前端;
  • 更多内容请参考《X Window System》。
  注意:在某些设备上,X11下没有EGL和OpenGL支持,因为EGL实现与Xlib不兼容。在这种情况下,XCB插件是在没有EGL支持的情况下构建的,这意味着Qt Quick 2或其他基于OpenGL的应用程序无法与此平台插件一起使用。但是,它仍然可以用于运行软件渲染的应用程序(例如,基于QWidget)。
  通常,不建议在嵌入式设备上使用XCB。像 EGLFS这样的插件可能会提供更好的性能和硬件加速。
  (2) Qt Creator具体配置如下:
  

  • 点击左侧【项目】 — 【ubuntu_rk3588_debian11_qt6】 — 【构建】;
  • 右侧【运行配置】 — 【运行】 — 【Command line arguments】输入: -platform xcb;
  • 选中右侧【运行配置】 — 【运行】 — 【X11 Forwarding】中的Forward to local display ,从而实现远程开辟板应用程序GUI在宿主机上展示,具体原理参考《快速理解X server, DISPLAY与X11 Forwarding》;如果未配置,控制台会出现如下错误;
     
    点击左侧【运行】图标,运行程序;
     
    尝试在开辟板debain桌面终端运行Qt程序,开辟板毗连的显示屏可以正常显示;
     
    1.9.7 运行脚本

  我们编写run_xcb.sh脚本指定Qt程序以xcb方式方式;
  1. pi@NanoPC-T6:/opt$ sudo vim run_xcb.sh
  2. #! /bin/bash
  3. # 指定应用程序图形界面显示在第0号X server.该X server管理的第0号screen
  4. export DISPLAY=:0.0
  5. # 导出qtdemo的安装目录
  6. export APP_DIR=/usr/local/bin
  7. # 指定qt库路径
  8. export LD_LIBRARY_PATH=/opt/qt6.5/lib
  9. # 指定qt插件路径
  10. export QT_QPA_PLATFORM_PLUGIN_PATH=/opt/6.5/plugins
  11. # 指定平台,通过QT_QPA_PLATFORM 或者-platform命令行选项指定其他设置
  12. export QT_QPA_PLATFORM=xcb
  13. echo "start demo1 APP..."
  14. #运行FireApp
  15. $APP_DIR/demo1
  16. pi@NanoPC-T6:/opt$ sudo chmod +x run_xcb.sh
  17. pi@NanoPC-T6:/opt$ ./run_xcb.sh
复制代码
二、开辟板安装Qt5和Qt Creator

  2.1 安装Qt5和Qt Creator

  本节我们直接使用aptitude将Qt5安装到NanoPC-T6开辟板的debain体系中。
  2.1 下令安装

  起首将debian的软件更新:
  1. pi@NanoPC-T6:/$ sudo aptitude update
复制代码
接着检察一下有没有安装Qt:
  1. pi@NanoPC-T6:/$ sudo apt list --installed | grep qtcreator
复制代码
如果未安装,那么安装Qt,这里安装的版本为Qt5.x,默认安装的是该大版本下的最新版本:
  1. pi@NanoPC-T6:/$ sudo aptitude install qtbase5-dev qtdeclarative5-dev qtchooser qt5-qmake qtbase5-dev-tools fcitx-frontend-qt5
  2. pi@NanoPC-T6:/$ sudo aptitude install qtcreator
  3. pi@NanoPC-T6:/$ sudo aptitude install "~n^qt5"
  4. pi@NanoPC-T6:/$ sudo apt install libqt5multimedia*  qtmultimedia5-*
复制代码
此中:
  

  • qtcreator是一套可视化的集成开辟环境,使用Qt Creator可以高效的进行Qt开辟;
  • qtbase5-dev: 这个包包含了Qt5的基本开辟文件,包括头文件和静态库。它是进行Qt5应用程序开辟的基础;
  • qtchooser: 这个包是一个工具,用于选择不同版本的Qt工具链,例如qmake和moc;
  • qt5-qmake: 这个包提供了Qt5的构建工具qmake。qmake是一个跨平台的项目管理工具,可以资助您构建和管理Qt5项目;
  • qtbase5-dev-tools: 这个包包含了一些辅助开辟工具,例如Qt5的文档生成工具、Qt5 Assistant资助检察器等;
  • fcitx-frontend-qt5:是一个用于在Qt5应用程序中支持Fcitx输入法框架的前端库。Fcitx是一个流行的开源输入法框架,而 fcitx-frontend-qt5则允许Qt5应用程序与Fcitx输入法进行集成。
  2.1.2 安装目次

  Qt默认是安装到/usr/lib/aarch64-linux-gnu/qt5目次,这里安装的版本为Qt 5.15.2;
  1. root@NanoPC-T6:~# ls -l /usr/lib/aarch64-linux-gnu | grep qt
  2. lrwxrwxrwx  1 root root       24  9月  7  2020 libgsettings-qt.so.1 -> libgsettings-qt.so.1.0.0
  3. lrwxrwxrwx  1 root root       24  9月  7  2020 libgsettings-qt.so.1.0 -> libgsettings-qt.so.1.0.0
  4. -rw-r--r--  1 root root    38848  9月  7  2020 libgsettings-qt.so.1.0.0
  5. lrwxrwxrwx  1 root root       24  9月  4  2022 libpoppler-qt5.so.1 -> libpoppler-qt5.so.1.25.0
  6. -rw-r--r--  1 root root   513904  9月  4  2022 libpoppler-qt5.so.1.25.0
  7. lrwxrwxrwx  1 root root       19  1月 12  2020 libqt5keychain.so -> libqt5keychain.so.1
  8. -rw-r--r--  1 root root   145344  1月 12  2020 libqt5keychain.so.0.10.0
  9. lrwxrwxrwx  1 root root       24  1月 12  2020 libqt5keychain.so.1 -> libqt5keychain.so.0.10.0
  10. lrwxrwxrwx  1 root root       21  4月 12  2020 libqt5qevercloud.so -> libqt5qevercloud.so.3
  11. lrwxrwxrwx  1 root root       25  4月 12  2020 libqt5qevercloud.so.3 -> libqt5qevercloud.so.3.0.3
  12. -rw-r--r--  1 root root   993240  4月 12  2020 libqt5qevercloud.so.3.0.3
  13. lrwxrwxrwx  1 root root       26  1月  8  2021 libqt5-ukui-style.so.1 -> libqt5-ukui-style.so.1.0.0
  14. lrwxrwxrwx  1 root root       26  1月  8  2021 libqt5-ukui-style.so.1.0 -> libqt5-ukui-style.so.1.0.0
  15. -rw-r--r--  1 root root   145352  1月  8  2021 libqt5-ukui-style.so.1.0.0
  16. drwxr-xr-x  1 root root     4096 12月 20 19:20 qt5
  17. drwxr-xr-x  2 root root     4096 12月 20 19:18 qtchooser
  18. drwxr-xr-x  3 root root     4096 12月 20 19:19 qtcreator
  19. drwxr-xr-x  3 root root     4096  6月 29 17:50 qt-default
  20. root@NanoPC-T6:~# ls -l /usr/lib/aarch64-linux-gnu/qt5
  21. drwxr-xr-x  2 root root 4096 12月 20 19:20 bin
  22. drwxr-xr-x  1 root root 4096 12月 20 19:20 examples
  23. drwxr-xr-x  2 root root 4096 12月 20 19:20 libexec
  24. drwxr-xr-x 77 root root 4096 12月 20 19:18 mkspecs
  25. drwxr-xr-x  1 root root 4096 12月 20 19:20 plugins
  26. drwxr-xr-x  1 root root 4096 12月 20 19:19 qml
  27. -rw-r--r--  1 root root  562  7月  2  2021 qt.conf
  28. root@NanoPC-T6:~# ls -l /usr/lib/aarch64-linux-gnu/qt5/bin/
  29. lrwxrwxrwx 1 root root 26  2月 26  2021 assistant -> ../../../qt5/bin/assistant
  30. lrwxrwxrwx 1 root root 33  7月  2  2021 fixqt4headers.pl -> ../../../qt5/bin/fixqt4headers.pl
  31. lrwxrwxrwx 1 root root 20  7月  2  2021 moc -> ../../../qt5/bin/moc
  32. lrwxrwxrwx 1 root root 29  7月  2  2021 qdbuscpp2xml -> ../../../qt5/bin/qdbuscpp2xml
  33. lrwxrwxrwx 1 root root 29  7月  2  2021 qdbusxml2cpp -> ../../../qt5/bin/qdbusxml2cpp
  34. lrwxrwxrwx 1 root root 22  7月  2  2021 qlalr -> ../../../qt5/bin/qlalr
  35. lrwxrwxrwx 1 root root 39  7月  2  2021 qmake -> ../../../../bin/aarch64-linux-gnu-qmake
  36. lrwxrwxrwx 1 root root 20  7月  2  2021 rcc -> ../../../qt5/bin/rcc
  37. lrwxrwxrwx 1 root root 26  7月  2  2021 syncqt.pl -> ../../../qt5/bin/syncqt.pl
  38. lrwxrwxrwx 1 root root 20  7月  2  2021 uic -> ../../../qt5/bin/uic
  39. root@NanoPC-T6:~#  qmake -v
  40. QMake version 3.1
  41. Using Qt version 5.15.2 in /usr/lib/aarch64-linux-gnu
复制代码
同时在路径/usr/lib/aarch64-linux-gnu/下有qt5的安装库;
  1. root@NanoPC-T6:~#  ls -l /usr/lib/aarch64-linux-gnu | grep Qt5
  2. -rw-r--r--  1 root root      963  7月  2  2021 libQt5Concurrent.prl
  3. lrwxrwxrwx  1 root root       26  7月  2  2021 libQt5Concurrent.so -> libQt5Concurrent.so.5.15.2
  4. lrwxrwxrwx  1 root root       26  7月  2  2021 libQt5Concurrent.so.5 -> libQt5Concurrent.so.5.15.2
  5. lrwxrwxrwx  1 root root       26  7月  2  2021 libQt5Concurrent.so.5.15 -> libQt5Concurrent.so.5.15.2
  6. -rw-r--r--  1 root root    27080  7月  2  2021 libQt5Concurrent.so.5.15.2
  7. -rw-r--r--  1 root root      967  7月  2  2021 libQt5Core.prl
  8. lrwxrwxrwx  1 root root       20  7月  2  2021 libQt5Core.so -> libQt5Core.so.5.15.2
  9. lrwxrwxrwx  1 root root       20  7月  2  2021 libQt5Core.so.5 -> libQt5Core.so.5.15.2
  10. lrwxrwxrwx  1 root root       20  7月  2  2021 libQt5Core.so.5.15 -> libQt5Core.so.5.15.2
  11. -rw-r--r--  1 root root  5588424  7月  2  2021 libQt5Core.so.5.15.2
  12. -rw-r--r--  1 root root      944  7月  2  2021 libQt5DBus.prl
  13. lrwxrwxrwx  1 root root       20  7月  2  2021 libQt5DBus.so -> libQt5DBus.so.5.15.2
  14. lrwxrwxrwx  1 root root       20  7月  2  2021 libQt5DBus.so.5 -> libQt5DBus.so.5.15.2
  15. lrwxrwxrwx  1 root root       20  7月  2  2021 libQt5DBus.so.5.15 -> libQt5DBus.so.5.15.2
  16. -rw-r--r--  1 root root   568448  7月  2  2021 libQt5DBus.so.5.15.2
  17. .....
复制代码
2.2 Qt配置

  安装完成后,我们进入debian桌面体系,可以看到Qt Creater;如果是以root用户登录的话,可以直接双击图标,启动程序;
     
    否则开启一个终端,使用如下下令启动Qt Creater;
  1. pi@NanoPC-T6:/$ sudo qtcreator
复制代码
点击【工具】-【外部】- 【Configure】,进入配置页面。
  2.2.1 编译器

  点击左侧【Kits】,选择【编译器】,这里已经检测到体系安装的C、C++编译器;当然如果有需求的话,也可以本身添加编译器,指定名称和编译器路径即可:
     
    这里我们只关注C、C++中的第一个,即/usr/bin/gcc、/usr/bin/g++;
  1. root@NanoPC-T6:~# gcc -v
  2. Using built-in specs.
  3. COLLECT_GCC=gcc
  4. COLLECT_LTO_WRAPPER=/usr/lib/gcc/aarch64-linux-gnu/10/lto-wrapper
  5. Target: aarch64-linux-gnu
  6. Thread model: posix
  7. Supported LTO compression algorithms: zlib zstd
  8. gcc version 10.2.1 20210110 (Debian 10.2.1-6)
  9. root@NanoPC-T6:~# g++ -v
  10. Using built-in specs.
  11. COLLECT_GCC=g++
  12. COLLECT_LTO_WRAPPER=/usr/lib/gcc/aarch64-linux-gnu/10/lto-wrapper
  13. Target: aarch64-linux-gnu
  14. Thread model: posix
  15. Supported LTO compression algorithms: zlib zstd
  16. gcc version 10.2.1 20210110 (Debian 10.2.1-6)
复制代码
可以看到体系中安装了gcc 10.2.1版本和gcc 10.2.1版本。
  2.2.2 Qt Vsersions

  点击左侧【Kits】,选择【Qt Vsersions】,可以手动设置qmake路径,这里默认值为/usr/lib/qt5/bin/qmake;
     
    这里我们检察一下/usr/lib/qt5目次:
  1. root@NanoPC-T6:~#  ls -l /usr/lib/qt5/
  2. drwxr-xr-x 2 root root 4096 12月 20 19:20 bin
  3. root@NanoPC-T6:~#  ls -l /usr/lib/qt5/bin/
  4. -rwxr-xr-x 1 root root  881184  2月 26  2021 assistant
  5. -rwxr-xr-x 1 root root    6340  7月  2  2021 fixqt4headers.pl
  6. -rwxr-xr-x 1 root root  953472  7月  2  2021 moc
  7. -rwxr-xr-x 1 root root  270096  7月  2  2021 qdbuscpp2xml
  8. -rwxr-xr-x 1 root root   64608  7月  2  2021 qdbusxml2cpp
  9. -rwxr-xr-x 1 root root  125880  7月  2  2021 qlalr
  10. -rwxr-xr-x 1 root root 2764360  7月  2  2021 qmake
  11. -rwxr-xr-x 1 root root   35440  7月  2  2021 qvkgen
  12. -rwxr-xr-x 1 root root  855136  7月  2  2021 rcc
  13. -rwxr-xr-x 1 root root   48360  7月  2  2021 syncqt.pl
  14. -rwxr-xr-x 1 root root  605208  7月  2  2021 tracegen
  15. -rwxr-xr-x 1 root root  540592  7月  2  2021 uic
复制代码
2.2.3 定义构建套件

  点击左侧【Kits】,选择【Kits】,添加套件:
     
    2.3 示例教程

  2.3.1 运行

  我们直接选择一个示例教程,如图所示:
     
    选中项目Qt Quick Demo - Clocks。
  打开项目后,选中左侧【项目】- 【桌面】-【Build & Run】- 【Run】,然后点击左下角【Run】图标按钮;
     
    测试如果返如今编译输出窗口出现如下错误;
  1. Project ERROR: Unknown module(s) in QT: qml quick
复制代码
需要安装如下依靠包:
  1. pi@NanoPC-T6:/$ sudo aptitude install qtdeclarative5-dev
复制代码
安装完成后,重新运行程序,运行结果如下:
     
    2.3.2 目次结构

  项目代码位于/usr/lib/aarch64-linux-gnu/qt5/examples/demos/clocks/ :
  1. root@NanoPC-T6:~# ls /usr/lib/aarch64-linux-gnu/qt5/examples/demos/clocks/ -l
  2. -rwxr-xr-x 1 root root 674816 12月 20 20:13 clocks
  3. -rw-r--r-- 1 root root    285 11月  6  2020 clocks.pro
  4. -rw-r--r-- 1 root root  21833 12月 20 20:02 clocks.pro.user
  5. -rw-r--r-- 1 root root   3932 11月  6  2020 clocks.qml
  6. -rw-r--r-- 1 root root    167 11月  6  2020 clocks.qmlproject
  7. -rw-r--r-- 1 root root    503 11月  6  2020 clocks.qrc
  8. drwxr-xr-x 2 root root   4096 12月 20 19:20 content
  9. -rw-r--r-- 1 root root   3076 11月  6  2020 main.cpp
  10. -rw-r--r-- 1 root root 918736 12月 20 20:13 main.o
  11. -rw-r--r-- 1 root root  18187 12月 20 20:13 Makefile
  12. -rw-r--r-- 1 root root 536820 12月 20 20:13 qrc_clocks.cpp
  13. -rw-r--r-- 1 root root 112056 12月 20 20:13 qrc_clocks.o
复制代码
一些工程文件的解释:
  

  • .h .cpp文件为头文件和源文件,我们的代码通常都是写在这两种文件中的;
  • .ui文件就是我们前面提到界面文件,实在质是xml格式的文本文件;
  • .pro文件就是工程管理文件,以qmake特有的语法记载了工程的文件和配置;
  • .pri文件通常也用于工程管理,将代码整理成一个模块,通过引入pri文件来引入代码模块;
  • .pro.user为用户描述文件,记载了我们工程的开辟环境构建环境等等,也是xml格式的文本文件;
  • .qrc除上面的文件,工程中一般还会有qrc资源文件,用于记载图片,音视频等文件。
  三、opencv安装及配置

  3.1 安装opencv

  3.1.1 安装依靠

  起首安装依靠项:
  1. pi@NanoPC-T6:/$ sudo aptitude install cmake
  2. pi@NanoPC-T6:/$ sudo aptitude install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev libatlas-base-dev gfortran libgtk2.0-dev libjpeg-dev libpng-dev ffmpeg
复制代码
此中:
  

  • libavcodec-dev: 提供了音频和视频编解码器的开辟库,用于处理音视频数据的编解码;
  • libavformat-dev: 包含了音视频封装格式处理的开辟库,用于读取和写入不同的音视频封装格式;
  • libswscale-dev: 提供了用于图像缩放和颜色空间转换的开辟库;
  • libv4l-dev: 提供了v4l2的开辟库,用于访问视频设备;
  • libxvidcore-dev: 提供了Xvid视频编解码器的开辟库;
  • libx264-dev: 提供了x264视频编码器的开辟库;
  • libatlas-base-dev: ATLAS是一个开源的数学库,提供了BLAS和LAPACK等线性代数函数的优化实现,这个包提供了ATLAS的开辟文件;
  • gfortran: GNU Fortran编译器,用于编译Fortran语言的程序;
  • libgtk2.0-dev: GTK+图形用户界面工具包的开辟文件,用于开辟基于GTK+的图形界面应用程序;
  • libjpeg-dev: 提供了JPEG图像格式的处理库的开辟文件;
  • libpng-dev: 提供了PNG图像格式的处理库的开辟文件;
  3.1.2 下载opencv

  在windows体系下载opencv-3.4.14.zip,并拷贝到开辟板debian体系;
  解压:
  1. pi@NanoPC-T6:/$ sudo cd /opt
  2. pi@NanoPC-T6:opt/$ sudo unzip opencv-3.4.14.zip
复制代码
3.2 编译安装

  3.2.1 编译安装

  进opencv-3.4.14文件夹,在该目次下新建一个build文件夹,实行如下下令:
  1. pi@NanoPC-T6:opt/$ cd opencv-3.4.14
  2. pi@NanoPC-T6:/opt/opencv-3.4.14$ sudo mkdir build
  3. pi@NanoPC-T6:/opt/opencv-3.4.14$ cd build
  4. pi@NanoPC-T6:/opt/opencv-3.4.14/build$ sudo cmake
  5. pi@NanoPC-T6:/opt/opencv-3.4.14/build$ sudo make -j7                   # 执行make开始编译,这个时间比较长,耐心等待。
  6. pi@NanoPC-T6:/opt/opencv-3.4.14/build$ sudo make install       # 安装
复制代码
默认安装到/usr/local路径下;比如:
  

  • /usr/local/include/opencv、/usr/local/include/opencv2:头文件安装目次;
  • /usr/local/lib:库文件安装目次;
  1. pi@NanoPC-T6:/opt/opencv-3.4.14/build$ ls /usr/local/lib/
  2. libopencv_calib3d.so            libopencv_flann.so.3.4.14      libopencv_objdetect.so.3.4     libopencv_videoio.so
  3. libopencv_calib3d.so.3.4        libopencv_highgui.so           libopencv_objdetect.so.3.4.14  libopencv_videoio.so.3.4
  4. libopencv_calib3d.so.3.4.14     libopencv_highgui.so.3.4       libopencv_photo.so             libopencv_videoio.so.3.4.14
  5. libopencv_core.so               libopencv_highgui.so.3.4.14    libopencv_photo.so.3.4         libopencv_video.so
  6. libopencv_core.so.3.4           libopencv_imgcodecs.so         libopencv_photo.so.3.4.14      libopencv_video.so.3.4
  7. libopencv_core.so.3.4.14        libopencv_imgcodecs.so.3.4     libopencv_shape.so             libopencv_video.so.3.4.14
  8. libopencv_dnn.so                libopencv_imgcodecs.so.3.4.14  libopencv_shape.so.3.4         libopencv_videostab.so
  9. libopencv_dnn.so.3.4            libopencv_imgproc.so           libopencv_shape.so.3.4.14      libopencv_videostab.so.3.4
  10. libopencv_dnn.so.3.4.14         libopencv_imgproc.so.3.4       libopencv_stitching.so         libopencv_videostab.so.3.4.14
  11. libopencv_features2d.so         libopencv_imgproc.so.3.4.14    libopencv_stitching.so.3.4     pkgconfig
  12. libopencv_features2d.so.3.4     libopencv_ml.so                libopencv_stitching.so.3.4.14  python3.9
  13. libopencv_features2d.so.3.4.14  libopencv_ml.so.3.4            libopencv_superres.so
  14. libopencv_flann.so              libopencv_ml.so.3.4.14         libopencv_superres.so.3.4
  15. libopencv_flann.so.3.4          libopencv_objdetect.so         libopencv_superres.so.3.4.14
  16. pi@NanoPC-T6:/opt/opencv-3.4.14/build$ ls /usr/local/include/opencv
  17. cvaux.h  cvaux.hpp  cv.h  cv.hpp  cvwimage.h  cxcore.h  cxcore.hpp  cxeigen.hpp  cxmisc.h  highgui.h  ml.h
  18. pi@NanoPC-T6:/opt/opencv-3.4.14/build$ ls /usr/local/include/opencv2/
  19. calib3d      dnn             flann.hpp      imgproc      objdetect.hpp       shape          superres.hpp  videostab
  20. calib3d.hpp  dnn.hpp         highgui        imgproc.hpp  opencv.hpp          shape.hpp      video         videostab.hpp
  21. core         features2d      highgui.hpp    ml           opencv_modules.hpp  stitching      video.hpp
  22. core.hpp     features2d.hpp  imgcodecs      ml.hpp       photo               stitching.hpp  videoio
  23. cvconfig.h   flann           imgcodecs.hpp  objdetect    photo.hpp           superres       videoio.hpp
复制代码
2.2.2 错误处理

  编译过程中可能出现若干错误,如果出现如下错误,可以按照如下方法进行处理;
  (1) -Werror=address错误,具体如下:
  1. [ 32%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/persistence_json.cpp.o
  2. /opt/opencv-3.4.14/modules/core/src/persistence_base64.cpp: In function ‘bool base64::base64_valid(const uint8_t*, size_t, size_t)’:
  3. /opt/opencv-3.4.14/modules/core/src/persistence_base64.cpp:167:31: error: comparing the result of pointer addition ‘(src + ((sizetype)off))’ and NULL [-Werror=address]
  4.   167 |     if (src == 0 || src + off == 0)
  5.       |                     ~~~~~~~~~~^~~~
  6. [ 32%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/persistence_types.cpp.o
  7. cc1plus: some warnings being treated as errors
  8. make[2]: *** [modules/core/CMakeFiles/opencv_core.dir/build.make:971:modules/core/CMakeFiles/opencv_core.dir/src/persistence_base64.cpp.o] 错误 1
  9. make[2]: *** 正在等待未完成的任务....
  10. make[1]: *** [CMakeFiles/Makefile2:1997:modules/core/CMakeFiles/opencv_core.dir/all] 错误 2
  11. make: *** [Makefile:166:all] 错误 2
复制代码
定位到opencv-3.4.14/cmake/OpenCVCompilerOptions.cmake文件,移除大概解释掉124行如下内容:
  1. add_extra_compiler_option(-Werror=address)
复制代码
(2) CODEC_ID_H264错误,具体如下:
  1. [ 52%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/convolution_layer.cpp.o
  2. /opt/opencv-3.4.14/modules/videoio/src/ffmpeg_codecs.hpp:81:26: error: ‘CODEC_ID_H264’ was not declared in this scope; did you mean ‘AV_CODEC_ID_H264’?
  3.    81 | #define AV_CODEC_ID_H264 CODEC_ID_H264
  4.       |                          ^~~~~~~~~~~~~
  5. /opt/opencv-3.4.14/modules/videoio/src/ffmpeg_codecs.hpp:146:7: note: in expansion of macro ‘AV_CODEC_ID_H264’
  6.   146 |     { AV_CODEC_ID_H264, MKTAG('H', '2', '6', '4') },
  7.       |       ^~~~~~~~~~~~~~~~
  8. /opt/opencv-3.4.14/modules/videoio/src/ffmpeg_codecs.hpp:81:26: error: ‘CODEC_ID_H264’ was not declared in this scope; did you mean ‘AV_CODEC_ID_H264’?
  9.    81 | #define AV_CODEC_ID_H264 CODEC_ID_H264
  10.    ......
复制代码
解决方案:在make之前,cmake直接关闭ffmpeg,在背面加上:
  1. pi@NanoPC-T6:/opt/opencv-3.4.14/build$ cd ..
  2. pi@NanoPC-T6:/opt/opencv-3.4.14$ sudo rm -rf CMakeCache.txt
  3. pi@NanoPC-T6:/opt/opencv-3.4.14/build$ sudo cmake ../ -D WITH_FFMPEG=OFF
复制代码
3.3 配置

  配置动态链接库,编辑/etc/ld.so.conf,文末参加/usr/local/lib,实行sudo /sbin/ldconfig -v生效;
  1. pi@NanoPC-T6:/opt/opencv-3.4.14$ sudo vim /etc/ld.so.conf
  2. include /etc/ld.so.conf.d/*.conf
  3. /usr/local/lib
  4. pi@NanoPC-T6:/opt/opencv-3.4.14$ sudo /sbin/ldconfig -v
复制代码
如果是交织编译,同时记得重新更新宿主机的sysroot目次;
  1. sudo mkdir -p /opt/qt6.5/sysroot
  2. cd /opt/qt6.5/sysroot
  3. sudo mkdir usr
  4. sudo mkdir lib
  5. sudo mkdir opt
  6. sudo mkdir local
  7. sudo cp -arvx /lib/* ./lib
  8. sudo cp -arvx /usr/include ./usr
  9. sudo cp -arvx /usr/lib ./usr
  10. sudo cp -arvx /usr/local ./usr
  11. sudo rm -rf /opt/qt6.5/sysroot/usr/lib/modules/6.1.25/
  12. sudo find -type l -lname '/*' -exec sh -c 'ln -sf "/opt/qt6.5/sysroot$(readlink "$0")" "$0"' {} \;
  13. ls /opt/qt6.5/sysroot/lib/aarch64-linux-gnu/libm.so -l
复制代码
参考文章
  [1] Linux下基于qt的视频监控体系
  [2] Linux Ubuntu搭建Qt RK3399编译 运行 调试环境
  [3] 嵌入式Linux--交织编译安装Qt5.12.9
  [4] linux GUI-移植QT5.6到mini2440
  [5] 在Ubuntu Linux上从源代码构建Qt 6.2.2的简短教程
  [6] RK3588安装Qt+opencv+收罗USB摄像头画面
  [7] QT使用OpenCV实现摄像头显示实时图像
  [8] Linux下Qt配置opencv环境(ippicv,ffmpeg手动配置)
  [9] https://www.debian.org/mirror/list
  [10] Ubuntu20 源码编译安装QT6.0 教程
  [11] 官方编译Qt教程
  [12] Cross-Compile Qt 6 for Raspberry Pi

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

西河刘卡车医

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表