qt5.9.8 编译到 海思3536
参考文章: https://blog.csdn.net/litao31415/article/details/100144400?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Edefault-5.baidujs&dist_request_id=&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Edefault-5.baidujs
/////////////////////////////////////////
# 解压
xz -d qt-everywhere-opensource-src-5.9.8.tar.xz
tar -xf qt-everywhere-opensource-src-5.9.8.tar
# 进入平台配置目录
cd qt-everywhere-opensource-src-5.9.8/qtbase/mkspecs
# 复制linux-arm-gnueabi-g++目录为linux-hi3536-g++
cp -dr linux-arm-gnueabi-g++ linux-hi3536-g++
/*************************/
# 修改 qmake.conf,配置如下
#
# qmake configuration for building with arm-linux-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)
DEFINES += EGL_FBDEV
# gpu 注意路径为Hi3536的SDK目录
QMAKE_INCDIR_EGL += /home/avcit/Hi3536_SDK_V2.0.6.0/mpp_master/component/gpu/release/include
QMAKE_LIBDIR_EGL += /home/avcit/Hi3536_SDK_V2.0.6.0/mpp_master/component/gpu/release/lib
QMAKE_LIBS_EGL += -lmali
QMAKE_INCDIR_OPENGL_ES2 += /home/avcit/Hi3536_SDK_V2.0.6.0/mpp_master/component/gpu/release/include
QMAKE_LIBDIR_OPENGL_ES2 += /home/avcit/Hi3536_SDK_V2.0.6.0/mpp_master/component/gpu/release/lib
QMAKE_LIBS_OPENGL_ES2 += -lmali
EGLFS_DEVICE_INTEGRATION = eglfs_mali
# modifications to g++.conf
#或者加入海思的一些编译选项 -march=armv7-a -mfloat-abi=softfp -mfpu=neon-vfpv4 -mno-unaligned-access -fno-aggressive-loop-optimizations
#注意编译器版本必须是hisiv400,因为SDK里面GPU的库是使用hisiv400编译的,用hisiv300会链接失败,qt configure无法通过
QMAKE_CC = arm-hisiv400-linux-gcc
QMAKE_CXX = arm-hisiv400-linux-g++
QMAKE_LINK = arm-hisiv400-linux-g++
QMAKE_LINK_SHLIB = arm-hisiv400-linux-g++
# modifications to linux.conf
QMAKE_AR = arm-hisiv400-linux-ar cqs
QMAKE_OBJCOPY = arm-hisiv400-linux-objcopy
QMAKE_NM = arm-hisiv400-linux-nm -P
QMAKE_STRIP = arm-hisiv400-linux-strip
load(qt_config)
/***********************************/
修改好交叉编译工具链后,就可以生成可用的makefile了
./configure -prefix /opt/qt598_hi3536_gpu -opensource -confirm-license -release \
-strip -eglfs -linuxfb -qt-zlib -no-gif -qt-libpng -qt-libjpeg -qt-freetype \
-no-rpath -no-pch -no-avx -no-openssl -no-cups -no-dbus -no-pkg-config \
-no-glib -no-iconv -xplatform linux-hi3536-g++ -make libs -opengl es2 \
-nomake examples -nomake tools -qt-sqlite
成功编译后发现生成的库太大了,其实可以裁剪一下,可改为:
./configure -prefix /opt/qt598_hi3536_gpu -opensource -confirm-license -release \
-strip -eglfs -linuxfb -qt-zlib -no-gif -qt-libpng -qt-libjpeg -qt-freetype \
-no-rpath -no-pch -no-avx -no-openssl -no-cups -no-dbus -no-pkg-config \
-no-glib -no-iconv -xplatform linux-hi3536-g++ -make libs -opengl es2 \
-nomake examples -nomake tools -qt-sqlite \
-skip qtgamepad \
-skip qtandroidextras \
-skip qtmacextras \
-skip qtx11extras \
-skip qtsensors \
-skip qtserialbus \
-skip qtserialport \
-skip qtwebengine \
-skip qtwebchannel \
-skip qtwebsockets \
-skip qtlocation \
-skip qtquickcontrols \
-skip qtpurchasing \
-skip qtconnectivity \
-skip qtscxml \
-skip qtxmlpatterns \
-skip qtnetworkauth \
-skip qtspeech \
-skip qtscript \
-skip qtremoteobjects \
-skip qtcharts \
-skip qtdatavis3d \
-skip qtwebview
当然,如果编译不出错的话,建议使用第一个configure,其实可以在写qt程序时,
根据用到什么库就拷贝什么库进海思的文件系统/lib/内,这样体积也会比较小!没必要通过configure裁剪
运行前,目标板需搭建好QT的运行环境:
#! /bin/sh
export GPU_LIB_PATH=/mnt/qt/gpu/lib
export QT_ROOT=/mnt/qt/qt598_hi3536_gpu
export QT_QPA_FONTDIR=$QT_ROOT/fonts
export QT_QPA_PLATFORM=eglfs
export QT_QPA_EGLFS_FB=/dev/fb0
export QT_QPA_PLATFORM_PLUGIN_PATH=$QT_ROOT/plugins
export QT_QPA_EGLFS_WIDTH=1920
export QT_QPA_EGLFS_HEIGHT=1080
export QT_QPA_EGLFS_PHYSICAL_WIDTH=320
export QT_QPA_EGLFS_PHYSICAL_HEIGHT=240
export QT_QPA_EGLFS_DEPTH=16
export QT_QPA_EGLFS_INTEGRATION=eglfs_mali
export QT_QPA_EGLFS_ALWAYS_SET_MODE=1
export QML_IMPORT_PATH=$QT_ROOT/qml
export QML2_IMPORT_PATH=$QT_ROOT/qml
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GPU_LIB_PATH:$QT_ROOT/lib
# for debug
#export QT_QPA_EGLFS_DEBUG=1
#export QT_LOGGING_RULES=qt.qpa.*=true
安装gpu驱动:
安装海思GPU库和驱动。Hi3536的GPU驱动和动态链接库在Hi3536_SDK_V2.0.6.0/mpp_master/component/gpu/release下面,将release目录拷贝到目标板的/lib下,并重命名为“gpu”。
使用" sh /lib/gpu/ko/loadgpu -i "加载以下GPU驱动:
kds.ko
hi_dbe.ko
mali_kbase.ko