QT5+OpenGL es2 + eglfs交叉编译安装(RK3399)

您所在的位置:网站首页 树莓派系统编译 QT5+OpenGL es2 + eglfs交叉编译安装(RK3399)

QT5+OpenGL es2 + eglfs交叉编译安装(RK3399)

2023-05-07 11:15| 来源: 网络整理| 查看: 265

QT5+OpenGL es2 + eglfs交叉编译安装(RK3399)

最近由于项目的需要,需要在aarch64 Ubuntu16.04中安装QT5,系统自带了一个qt5,但项目要求必须是qt5.12的版本并且需要包含opengl和eglfs的库,所以只能重新对移植QT5.12,下面把移植过程记录下。

下载QT5源码 下载地址:https://download.qt.io/archive/qt/ 找到自己需要的版本进行下载。

图中标出来的就是源码下载链接。随便下载哪一个都行。下载后放入ubuntu(我用的Ubuntu 16.04)系统中进行解压。

解压后进入源码路径。创建一个autoconfig.sh。写入下面内容

#!/bin/sh ./configure \ -sysroot /home/xxxx/project/target \ -extprefix /opt/qt5.12.11-aarch64 \ -confirm-license \ -opensource \ -release \ -make libs \ -xplatform linux-aarch64-gnu-g++ \ -pch \ -qt-libjpeg \ -qt-libpng \ -qt-zlib \ -no-sse2 \ -no-openssl \ -no-cups \ -no-glib \ -no-dbus \ -qt-xcb \ -no-separate-debug-info \ -opengl es2 \ -egl \ -eglfs \ -qpa eglfs \ -no-linuxfb \ -recheck-all

这里面有两个参数需要注意下。 -sysroot 指定根文件系统位置。交叉编译时指定目标文件系统的挂载路径。并且QT的交叉编译过程会在这个参数指定文件系统下查找所依赖的库和包含的头文件。 -prefix 指定编译完成后make install时的安装位置,如果系统中指定了sysroot参数,那么安装位置为sysroot+prefix。利用默认的安装位置时可以不用指定prefix参数。 -extprefix 这个参数和prefix 的作用差不多,只不多extprefix 指定的安装路径位置不添加sysroot指定的路径,例如:-extprefix /opt/qt5.12.11-aach64 那么make install后安装位置为编译主机的/opt/qt5.12.11-aach64目录中。 注:make install的具体安装位置可以在配置命令执行完成的log中看到。

修改编译工具链 修改文件:qtbase/mkspecs/linux-aarch64-gnu-g++/qmake.conf。这个需要根据自己目标机器的cpu架构进行修改。我用的是arm64的cpu,所以是linux-aarch64-gnu-g++/qmake.conf这个文件。其实这里具体用那个文件下的qmake.conf是和配置中的-xplatform参数对应的。

# modifications to g++.conf QMAKE_CC = aarch64-linux-gnu-gcc QMAKE_CXX = aarch64-linux-gnu-g++ QMAKE_LINK = aarch64-linux-gnu-g++ QMAKE_LINK_SHLIB = aarch64-linux-gnu-g++ # modifications to linux.conf QMAKE_AR = aarch64-linux-gnu-ar cqs QMAKE_OBJCOPY = aarch64-linux-gnu-objcopy QMAKE_NM = aarch64-linux-gnu-nm -P QMAKE_STRIP = aarch64-linux-gnu-strip

这里可以修改成交叉编译工具链的绝对路径。

添加QT支持OpenGL es2和eglfs库的路劲和头文件。

# # qmake configuration for building with aarch64-linux-gnu-g++ # MAKEFILE_GENERATOR = UNIX CONFIG += incremental QMAKE_INCREMENTAL_STYLE = sublib include(../common/linux.conf) include(../common/gcc-base-unix.conf) include(../common/g++-unix.conf) # modifications to g++.conf QMAKE_CC = aarch64-linux-gnu-gcc QMAKE_CXX = aarch64-linux-gnu-g++ QMAKE_LINK = aarch64-linux-gnu-g++ QMAKE_LINK_SHLIB = aarch64-linux-gnu-g++ # modifications to linux.conf QMAKE_AR = aarch64-linux-gnu-ar cqs QMAKE_OBJCOPY = aarch64-linux-gnu-objcopy QMAKE_NM = aarch64-linux-gnu-nm -P QMAKE_STRIP = aarch64-linux-gnu-strip QMAKE_INCDIR_OPENGL_ES2 = $$[QT_SYSROOT]/usr/include QMAKE_LIBDIR_OPENGL_ES2 = /usr/lib/aarch64-linux-gnu QMAKE_INCDIR_EGL = $$[QT_SYSROOT]/usr/include QMAKE_LIBDIR_EGL = /usr/lib/aarch64-linux-gnu QMAKE_LIBS_EGL += -lEGL -lGLESv2 QMAKE_LIBS_OPENGL_ES2 += -lGLESv2 -lEGL load(qt_config)

确定文件系统中包含opengl的库。可以在文件系统usr目录下找一下libEGL.so libGLESv2.so这两个库

find .| grep "EGL" find .| grep "GLESv2"

如果没有找到相应的库。可以通过下面命令安装。

sudo apt-get install libgles2-mesa sudo apt-get install libgles2-mesa-dev

注意上面的命令都是在挂载的目标机文件系统下操作。 安装上面的库时可以利用sudo chroot "挂载路径"进去后来为挂载的文件系统安装程序。

执行编译 经过上面的修改后执行下面命令执行配置和编译

./autoconfig.sh make sudo make install

如果配置过程中出错,需要先删除config.log和config.cache在重新执行autoconfig.sh进行配置。 配置阶段无误的话下面这几项会被选择

openGL ES系列…………yes EGL…………………………yes EGLFS……………………yes EGLFS Mali………………yes

QT部署 make install 编译好的QT系统会被安装到extprefix指定的目录中。copy打包这个目录并把它放在目标主机中相同的目录结构下,建议用tar的方式压缩,防止丢失符号链接。如果make install安装的目录需要管理员权限访问可以sudo make install。 配置环境变量 修改/etc/profile文件添加下面环境变量

export QTDIR=/opt/qt5.12.11-aarch64 export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH export QT_QPA_PLATFORM_PLUGIN_PATH=$QTDIR/plugins export QT_QPA_PLATFORM=eglfs

QT_QPA_PLATFORM这个环境变量可以不用指定,如果想用eglfs显示可以在运行QT程序的时候增加参数“-platform eglfs”。 如果想在sudo命令下正确的利用eglfs插件显示还需要在 /etc/environment中添加如下两行。 这里特别提一下export QT_DEBUG_PLUGINS=1这个环境变量,设置后会打印log。通过打印出来的log可以分析程序是在什么地方出错了,如果存在库的依赖不存在也会在log中指出是哪个位置的少什么样的库。个人感觉挺非常有用。

LD_LIBRARY_PATH=/opt/qt5.12.11-aarch64/lib QT_QPA_PLATFORM_PLUGIN_PATH=/opt/qt5.12.11-aarch64/plugins

移植过程错误解决 (1)QMAKE_INCDIR_OPENGL[_ES2]配置错误问题

出现上面问题的时候可以自己检查一下qtbase/mkspecs/linux-aarch64-gnu-g++/qmake.conf中对opengl的哪几项配置是不是有问题,能不能找到libEGL.so libGLESv2.so库和相关的头文件。是在找不到问题在哪可以试着执行rm config.*将配置过程中的临时文件删除掉在执行./autoconfig.sh试试。如果检查好都没啥问题还是报这样的错误,不防备份autoconfig.sh和qmake.conf文件,然后把QT的源码删除了重新解压一份在把autoconfig.sh和qmake.conf放在各自的录下,运行autoconfig.sh在试试。 注意我的qmake.config中指定的QMAKE_INCDIR_OPENGL_ES2、QMAKE_LIBDIR_OPENGL_ES2、QMAKE_INCDIR_EGL、QMAKE_LIBDIR_EGL不在同一文件系统中,具体原因看"编译生成的libqeglfs.so依赖库位置错误问题"中的介绍。 (2)EGLFS Mali 不能被选中,提示下面错误:

EGLFS Mali………………no

查找config.log会发现有提示fbdev_window *没有定义错误。网上查到两种解决办法 方案一、创建一个空的fbdev_window.h,结果报fbdev_window *没有定义; 方案二、创建一个软链接,将fbdev_window.h软链接到egl.h,结果如方案一所示。ln -s egl.h fbdev_window.h 试了上面两种方式都没有用,从log中提示的错误可以判断是少一个fbdev_window的类型。而上面哪两种方案其实都实际上没有把这个数据类型定义,所以才会失败。后来查找到下面的帖子,完美解决这个错误。https://blog.csdn.net/lixiaojun216/article/details/121602501。这里非常感谢博主的分享。 创建fbdev_window.h文件存放到目标文件系统的/usr/include/EGL目录下,头文件内容如下

/* 1. This confidential and proprietary software may be used only as 2. authorised by a licensing agreement from ARM Limited 3. (C) COPYRIGHT 2008-2011 ARM Limited 4. ALL RIGHTS RESERVED 5. The entire notice above must be reproduced on all authorised 6. copies and copies may only be made to the extent permitted 7. by a licensing agreement from ARM Limited. */ /** 8. @file fbdev_window.h 9. @brief A window type for the framebuffer device (used by egl and tests) */ #ifndef _FBDEV_WINDOW_H_ #define _FBDEV_WINDOW_H_ #ifdef __cplusplus extern "C" { #endif typedef enum { FBDEV_PIXMAP_DEFAULT = 0, FBDEV_PIXMAP_SUPPORTS_UMP = (1 2.16... yes Checking for jsoncpp... no Checking for khr... yes Checking for libevent... no Checking for libvpx... no Checking for libwebp, libwebpmux and libwebpdemux... no Checking for libxml2 and libxslt... no Checking for minizip... no Checking for system ninja... no Checking for nss >= 3.26... no Checking for opus... no Checking for protobuf... no Checking for re2... no Checking for snappy... no Checking for xcomposite... no Checking for xcursor... no Checking for xi... no Checking for xtst... no Done running configuration tests. Configure summary: Building on: linux-g++ (x86_64, CPU features: mmx sse sse2) Building for: linux-aarch64-gnu-g++ (arm64, CPU features: neon) Target compiler: gcc 5.4.0 Configuration: cross_compile use_gold_linker compile_examples enable_new_dtags largefile neon precompile_header shared rpath release c++11 c++14 concurrent reduce_exports stl Build options: Mode ................................... release Optimize release build for size ........ no Building shared libraries .............. yes Using C standard ....................... C11 Using C++ standard ..................... C++14 Using ccache ........................... no Using gold linker ...................... yes Using new DTAGS ........................ yes Using precompiled headers .............. yes Using LTCG ............................. no Target compiler supports: NEON ................................. yes Build parts ............................ libs Qt modules and options: Qt Concurrent .......................... yes Qt D-Bus ............................... no Qt D-Bus directly linked to libdbus .... no Qt Gui ................................. yes Qt Network ............................. yes Qt Sql ................................. yes Qt Testlib ............................. yes Qt Widgets ............................. yes Qt Xml ................................. yes Support enabled for: Using pkg-config ....................... yes udev ................................... no Using system zlib ...................... no Qt Core: DoubleConversion ....................... yes Using system DoubleConversion ........ no GLib ................................... no iconv .................................. yes ICU .................................... no Tracing backend ........................ Logging backends: journald ............................. no syslog ............................... no slog2 ................................ no Using system PCRE2 ..................... no Qt Network: getifaddrs() ........................... yes IPv6 ifname ............................ yes libproxy ............................... no Linux AF_NETLINK ....................... yes OpenSSL ................................ no Qt directly linked to OpenSSL ........ no OpenSSL 1.1 ............................ no DTLS ................................... no SCTP ................................... no Use system proxies ..................... yes Qt Gui: Accessibility .......................... yes FreeType ............................... yes Using system FreeType ................ no HarfBuzz ............................... yes Using system HarfBuzz ................ no Fontconfig ............................. no Image formats: GIF .................................. yes ICO .................................. yes JPEG ................................. yes Using system libjpeg ............... no PNG .................................. yes Using system libpng ................ no EGL .................................... yes OpenVG ................................. no OpenGL: Desktop OpenGL ....................... no OpenGL ES 2.0 ........................ yes OpenGL ES 3.0 ........................ yes OpenGL ES 3.1 ........................ yes OpenGL ES 3.2 ........................ yes Vulkan ................................. no Session Management ..................... yes Features used by QPA backends: evdev .................................. yes libinput ............................... no INTEGRITY HID .......................... no mtdev .................................. no tslib .................................. no xkbcommon .............................. yes X11 specific: XLib ................................. yes XCB Xlib ............................. yes EGL on X11 ........................... yes QPA backends: DirectFB ............................... no EGLFS .................................. yes EGLFS details: EGLFS OpenWFD ........................ no EGLFS i.Mx6 .......................... no EGLFS i.Mx6 Wayland .................. no EGLFS RCAR ........................... no EGLFS EGLDevice ...................... no EGLFS GBM ............................ no EGLFS VSP2 ........................... no EGLFS Mali ........................... yes EGLFS Raspberry Pi ................... no EGLFS X11 ............................ yes LinuxFB ................................ no VNC .................................... yes Mir client ............................. no XCB: Using system-provided XCB libraries .. no XCB XKB .............................. yes XCB XInput ........................... yes Native painting (experimental) ....... no GL integrations: GLX Plugin ......................... no EGL-X11 Plugin ..................... yes Qt Sql: SQL item models ........................ yes Qt Widgets: GTK+ ................................... no Styles ................................. Fusion Windows Qt PrintSupport: CUPS ................................... no Qt Sql Drivers: DB2 (IBM) .............................. no InterBase .............................. no MySql .................................. no OCI (Oracle) ........................... no ODBC ................................... no PostgreSQL ............................. no SQLite2 ................................ no SQLite ................................. yes Using system provided SQLite ......... no TDS (Sybase) ........................... no Qt Testlib: Tester for item models ................. yes Qt SerialBus: Socket CAN ............................. yes Socket CAN FD .......................... yes Further Image Formats: JasPer ................................. no MNG .................................... no TIFF ................................... yes Using system libtiff ................. no WEBP ................................... yes Using system libwebp ................. no Qt QML: QML network support .................... yes QML debugging and profiling support .... yes QML sequence object .................... yes QML list model ......................... yes QML XML http request ................... yes QML Locale ............................. yes QML delegate model ..................... yes Qt Quick: Direct3D 12 ............................ no AnimatedImage item ..................... yes Canvas item ............................ yes Support for Qt Quick Designer .......... yes Flipable item .......................... yes GridView item .......................... yes ListView item .......................... yes TableView item ......................... yes Path support ........................... yes PathView item .......................... yes Positioner items ....................... yes Repeater item .......................... yes ShaderEffect item ...................... yes Sprite item ............................ yes Qt Scxml: ECMAScript data model for QtScxml ...... yes Qt Gamepad: SDL2 ................................... no Qt 3D: Assimp ................................. yes System Assimp .......................... no Output Qt3D Job traces ................. no Output Qt3D GL traces .................. no Use SSE2 instructions .................. no Use AVX2 instructions .................. no Aspects: Render aspect ........................ yes Input aspect ......................... yes Logic aspect ......................... yes Animation aspect ..................... yes Extras aspect ........................ yes Qt 3D Renderers: OpenGL Renderer ........................ yes Qt 3D GeometryLoaders: Autodesk FBX ........................... no Qt Wayland Client ........................ no Qt Wayland Compositor .................... no Qt Bluetooth: BlueZ .................................. no BlueZ Low Energy ....................... no Linux Crypto API ....................... no WinRT Bluetooth API (desktop & UWP) .... no Qt Sensors: sensorfw ............................... no Qt Quick Controls 2: Styles ................................. Default Fusion Imagine Material Universal Qt Quick Templates 2: Hover support .......................... yes Multi-touch support .................... yes Qt Positioning: Gypsy GPS Daemon ....................... no WinRT Geolocation API .................. no Qt Location: Qt.labs.location experimental QML plugin . yes Geoservice plugins: OpenStreetMap ........................ yes HERE ................................. yes Esri ................................. yes Mapbox ............................... yes MapboxGL ............................. yes Itemsoverlay ......................... yes QtXmlPatterns: XML schema support ..................... yes Qt Multimedia: ALSA ................................... no GStreamer 1.0 .......................... no GStreamer 0.10 ......................... no Video for Linux ........................ yes OpenAL ................................. no PulseAudio ............................. no Resource Policy (libresourceqt5) ....... no Windows Audio Services ................. no DirectShow ............................. no Windows Media Foundation ............... no Qt Tools: QDoc ................................... no Qt WebEngine: Embedded build ......................... yes Full debug information ................. no Pepper Plugins ......................... no Printing and PDF ....................... no Proprietary Codecs ..................... no Spellchecker ........................... yes Native Spellchecker .................... no WebRTC ................................. no Use System Ninja ....................... no Geolocation ............................ yes WebChannel support ..................... yes Use v8 snapshot ........................ yes Kerberos Authentication ................ no Support qpa-xcb ........................ no Building v8 snapshot supported ......... yes Use ALSA ............................... no Use PulseAudio ......................... no Optional system libraries used: re2 .................................. no icu .................................. no libwebp, libwebpmux and libwebpdemux . no opus ................................. no ffmpeg ............................... no libvpx ............................... no snappy ............................... no glib ................................. no zlib ................................. no minizip .............................. no libevent ............................. no jsoncpp .............................. no protobuf ............................. no libxml2 and libxslt .................. no lcms2 ................................ no png .................................. no JPEG ................................. no harfbuzz ............................. no freetype ............................. no Required system libraries: fontconfig ........................... no dbus ................................. no nss .................................. no khr .................................. yes glibc ................................ yes Required system libraries for qpa-xcb: x11 .................................. yes libdrm ............................... no xcomposite ........................... no xcursor .............................. no xi ................................... no xtst ................................. no Note: Also available for Linux: linux-clang linux-icc Note: PKG_CONFIG_LIBDIR automatically set to /home/lincor/project/target/usr/lib/pkgconfig:/home/lincor/project/target/usr/share/pkgconfig:/home/lincor/project/target/usr/lib/aarch64-linux-gnu/pkgconfig Note: PKG_CONFIG_SYSROOT_DIR automatically set to /home/lincor/project/target Note: Disabling X11 Accessibility Bridge: D-Bus or AT-SPI is missing. Note: No wayland-egl support detected. Cross-toolkit compatibility disabled. WARNING: QDoc will not be compiled, probably because libclang could not be located. This means that you cannot build the Qt documentation. Either ensure that llvm-config is in your PATH environment variable, or set LLVM_INSTALL_DIR to the location of your llvm installation. On Linux systems, you may be able to install libclang by installing the libclang-dev or libclang-devel package, depending on your distribution. On macOS, you can use Homebrew's llvm package. On Windows, you must set LLVM_INSTALL_DIR to the installation path. WARNING: gperf is required to build QtWebEngine. Qt is now configured for building. Just run 'make'. Once everything is built, you must run 'make install'. Qt will be installed into '/opt/qt5.12.11-aarch64'. Prior to reconfiguration, make sure you remove any leftovers from the previous build.

经过上面的移植后eglfs插件可以正常运行,并且GPU功能也正常 展示一下显示效果:

结束语: 经历了3周多时间,终于是搞定了QT的移植,整个过程中踩了不少的坑,这里记录下来一是为了后面再遇到此类问题能有个参考,二也是分享一下自己经验,希望后来人在移植过程中少踩点坑。 能读到这里朋友,谢谢你对这片文章的支持。另外文章中大部分内容为手敲,错别字比较多,还望谅解。

QT5+OpenGL es2 + eglfs交叉编译安装(续)

eglplatform.h和fbdev_window.h下载下载: https://download.csdn.net/download/xuesong10210/76481431 交叉编译产物下载地址: https://download.csdn.net/download/xuesong10210/76495076

参考: https://blog.csdn.net/pengjiaqi1028/article/details/111476742 https://blog.csdn.net/lixiaojun216/article/details/121602501 https://blog.csdn.net/yuangc/article/details/118021354 https://blog.csdn.net/dieju8330/article/details/86743919 https://dev.t-firefly.com/thread-13087-1-9.html



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3