环境:ubuntu18.04 64位
qt版本:qt5.9.9
平台:hi3531dv100
编译工具:arm-hisiv600-linux-g++
1、QT5.9.9安装包下载
下载地址: 点我
选择qt-everywhere-opensource-src-5.9.9.tar.xz
2、解压
tar -xvf qt-everywhere-opensource-src-5.9.9.tar.xz
3、hi3531编译配置
cd qt-everywhere-opensource-src-5.9.9/qtbase/mkspecs
# 复制linux-arm-gnueabi-g++为arm-hisiv600-linux-g++
cp -ar linux-arm-gnueabi-g++ arm-hisiv600-linux-g++
修改 qmake.conf,配置如下:
#
# qmake configuration for building with arm-linux-gnueabi-g++
#
MAKEFILE_GENERATOR = UNIX
CONFIG += incremental
QMAKE_INCREMENTAL_STYLE = sublib
#QT_QPA_DEFAULT_PLATFORM = linuxfb
include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)
# modifications to g++.conf
QMAKE_CC = arm-hisiv600-linux-gcc
QMAKE_CXX = arm-hisiv600-linux-g++
QMAKE_LINK = arm-hisiv600-linux-g++
QMAKE_LINK_SHLIB = arm-hisiv600-linux-g++
# modifications to linux.conf
QMAKE_AR = arm-hisiv600-linux-ar cqs
QMAKE_OBJCOPY = arm-hisiv600-linux-objcopy
QMAKE_NM = arm-hisiv600-linux-nm -P
QMAKE_STRIP = arm-hisiv600-linux-strip
load(qt_config)
4、Qt编译参数(不含tslib)
./configure -prefix /opt/Qt-arm-5.9.9 \
-opensource \
-confirm-license \
-release \
-strip \
-no-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 arm-hisiv600-linux-g++ \
-no-opengl \
-nomake examples \
-nomake tools \
-no-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
说明:
-prefix: 安装目录
-xplatform: 平台选择
5、编译&安装
make -j4 & make install # -j4: 启用4线程同时编译,提升编译速度
6、移植
在目标板上/lib目录下创建Qt文件夹
将安装文件夹下的lib、plugins、和qml拷贝到目标板的/lib/Qt文件夹下
配置/etc/profile
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/Yhi/lib/Qt5.9.9/lib/
export QTDIR=/Yhi/lib/Qt5.9.9
export QT_QPA_PLATFORM_PLUGIN_PATH=$QTDIR/plugins
export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0:size=1920x1080
export QT_QPA_FONTDIR=$QTDIR/fonts
export QML_IMPORT_PATH=$QTDIR/qml
export QML2_IMPORT_PATH=$QTDIR/qml
7、framebuffer配置
static struct fb_bitfield s_a32 = {24,8,0};
static struct fb_bitfield s_r32 = {16,8,0};
static struct fb_bitfield s_g32 = {8,8,0};
static struct fb_bitfield s_b32 = {0,8,0};
HI_S32 hifb_fd = -1;
HI_S32 CMppManager::ConfigFrameBuffer()
{
HI_S32 s32Ret = HI_SUCCESS;
struct fb_var_screeninfo stVarInfo;
HI_CHAR file[12] = "/dev/fb0";
HI_BOOL bEnable;
HIFB_DDRZONE_S stDDRZonePara;
HIFB_LAYER_INFO_S stLayerinfo;
HI_S32 hifb_fd = -1;
strcpy(file, "/dev/fb0");
/* 1. open framebuffer device overlay 0 */
hifb_fd = open(file, O_RDWR, 0);
if(hifb_fd < 0)
{
SAMPLE_PRT("open %s failed!\n",file);
return HI_NULL;
}
s32Ret = ioctl (hifb_fd, FBIOGET_VSCREENINFO, &stVarInfo);
if (s32Ret < 0)
{
SAMPLE_PRT("FBIOGET_VSCREENINFO failed!\n");
close(hifb_fd);
return HI_NULL;
}
stVarInfo.red = s_r32;
stVarInfo.green = s_g32;
stVarInfo.blue = s_b32;
stVarInfo.transp = s_a32;
stVarInfo.bits_per_pixel = 32;
stVarInfo.xres=HD_WIDTH;
stVarInfo.yres=HD_HEIGHT;
stVarInfo.activate=FB_ACTIVATE_NOW;
stVarInfo.xres_virtual=HD_WIDTH;
stVarInfo.yres_virtual = HD_HEIGHT;
stVarInfo.xoffset=0;
stVarInfo.yoffset=0;
s32Ret = ioctl (hifb_fd, FBIOPUT_VSCREENINFO, &stVarInfo);
if (s32Ret < 0)
{
SAMPLE_PRT("FBIOPUT_VSCREENINFO failed!\n");
close(hifb_fd);
return HI_FAILURE;
}
s32Ret = ioctl(hifb_fd, FBIOGET_LAYER_INFO, &stLayerinfo);
if (s32Ret < 0)
{
SAMPLE_PRT("FBIOGET_LAYER_INFO failed!\n");
close(hifb_fd);
return HI_FAILURE;
}
stLayerinfo.u32Mask = 0;
stLayerinfo.BufMode = HIFB_LAYER_BUF_NONE;
stLayerinfo.u32Mask |= HIFB_LAYERMASK_BUFMODE;
s32Ret = ioctl(hifb_fd, FBIOPUT_LAYER_INFO, &stLayerinfo);
if (s32Ret < 0)
{
SAMPLE_PRT("FBIOPUT_LAYER_INFO failed!\n");
close(hifb_fd);
return HI_FAILURE;
}
stDDRZonePara.u32StartSection = 0;
stDDRZonePara.u32ZoneNums = 15;
s32Ret = ioctl(hifb_fd, FBIOPUT_MDDRDETECT_HIFB, &stDDRZonePara);
if (s32Ret < 0)
{
SAMPLE_PRT("FBIOPUT_MDDRDETECT_HIFB failed!\n");
close(hifb_fd);
return HI_FAILURE;
}
/* 2. open compress */
bEnable = HI_TRUE;
s32Ret = ioctl(hifb_fd, FBIOPUT_COMPRESSION_HIFB, &bEnable);
if (s32Ret < 0)
{
SAMPLE_PRT("FBIOPUT_COMPRESSION_HIFB failed!\n");
close(hifb_fd);
return HI_FAILURE;
}
system("/Yhi/NAND/RecordGUI/RecorderGUI &");
return HI_SUCCESS;
}