全志T7/T507 Qt5.12.5移植记录

28 篇文章 0 订阅
3 篇文章 0 订阅

1.概述
Qt5.12.5移植过程中遇到一些坑,特意记录下来。
主要包括编译、运行、环境配置三个部分。
2.编译配置
2.1.配置脚本
新建setenvs512.sh脚本,设置编译环境和选项,放入Qt源代码根目录。
示例:

#!/bin/sh

source ../../target/user_rootfs_misc/misc_config

if [ ${GNUEABI} == "gnueabihf" ];then
	echo "update g++"
	cp -rf ../linux-arm-gnueabi-g++/ qtbase/mkspecs/
fi
AW_QT_INSTALL_DIR=Qt-5.12.5
AW_QT_VER=5.12.5
export AW_LICHEE_ROOT=$PWD/../../..
export QT_BUILD_ROOT=$PWD
export QT_INSTALL_DIR=$QT_BUILD_ROOT/$AW_QT_INSTALL_DIR
export PATH=$AW_LICHEE_ROOT/out/${LICHEE_CHIP}/linux/common/buildroot/host/usr/bin/:$PATH
export SYSROOT=$AW_LICHEE_ROOT/out/${LICHEE_CHIP}/linux/common/buildroot/host/usr/arm-buildroot-linux-${GNUEABI}/sysroot
export CROSS_COMPILE_DIR=$AW_LICHEE_ROOT/out/${LICHEE_CHIP}/linux/common/buildroot/host/opt/ext-toolchain/bin/
export CROSS_COMPILE=$CROSS_COMPILE_DIR/arm-linux-${GNUEABI}-
export CPLUS_INCLUDE_PATH=$PWD/qtbase/src/3rdparty/angle/include:$CPLUS_INCLUDE_PATH
export QMAKEDIR=$QT_BUILD_ROOT/qmake
export PATH=$CROSS_COMPILE_DIR:$QT_INSTALL_DIR/bin:$PATH
function cqtroot
{
cd $QT_BUILD_ROOT
}
#-no-c++11
function makeconfig
{
	cp $AW_LICHEE_ROOT/tools/pack/chips/${LICHEE_CHIP}/hal/gpu/fbdev/lib/* $SYSROOT/lib/ -rf
	mkdir -p $QT_INSTALL_DIR

	$QT_BUILD_ROOT/configure \
		-opensource \
		-confirm-license \
		-extprefix $QT_INSTALL_DIR \
		-R /usr/lib \
		-no-strip \
		-c++std c++11 \
		-shared \
		-nomake examples \
		-accessibility \
		-no-sql-db2 -no-sql-ibase -no-sql-mysql -no-sql-oci \
		-no-sql-odbc -no-sql-psql -no-sql-sqlite2  -no-sql-tds \
 		-no-sql-sqlite -plugin-sql-sqlite \
		-no-qml-debug \
		-no-sse2 \
		-no-sse3 \
		-no-ssse3 \
		-no-sse4.1 \
		-no-sse4.2 \
		-no-avx \
		-no-avx2 \
		-no-mips_dsp \
		-no-mips_dspr2 \
		-qt-zlib \
		-no-journald \
		-qt-libpng \
		-qt-libjpeg \
		-qt-freetype \
		-qt-harfbuzz \
		-no-openssl \
		-no-xcb-xlib \
		-no-glib \
		-no-pulseaudio \
		-alsa \
		-gui \
		-widgets \
		-v \
		-optimized-qmake \
		-no-cups \
		-no-iconv \
		-evdev \
		-no-icu \
		-no-fontconfig \
		-no-strip \
		-pch \
		-dbus \
		-no-use-gold-linker \
		-xplatform linux-arm-gnueabi-g++ \
		-no-directfb \
		-eglfs \
		-qpa eglfs \
		-linuxfb \
		-no-kms \
		-sysroot $SYSROOT \
		-opengl es2 \
		-no-system-proxies \
		-no-slog2 \
		-no-pps \
		-no-imf \
		-no-lgmon \
		-tslib \
		-device-option CROSS_COMPILE=$CROSS_COMPILE
	sed -i '/^QMAKE_LIBS_OPENGL_ES2*/d' qtbase/src/gui/qtgui-config.pri
	sed -i '/^QMAKE_LIBS_EGL*/d' qtbase/src/gui/qtgui-config.pri

}

function makeall
{
	sed -i '/^QMAKE_LIBS_OPENGL_ES2*/d' qtbase/src/gui/qtgui-config.pri
	sed -i '/^QMAKE_LIBS_EGL*/d' qtbase/src/gui/qtgui-config.pri
	make -j 32 -C $QT_BUILD_ROOT
}

function makeinstall
{
	make -C $QT_BUILD_ROOT install
	local QT_TARGET_INSTALL=$AW_LICHEE_ROOT/out/${LICHEE_CHIP}/linux/common/buildroot/target/usr/local/$AW_QT_INSTALL_DIR
	mkdir -p $QT_TARGET_INSTALL
	cp -rf \
	$QT_INSTALL_DIR/lib $QT_INSTALL_DIR/plugins $QT_INSTALL_DIR/qml \
	$QT_INSTALL_DIR/translations $QT_TARGET_INSTALL
	cp $AW_LICHEE_ROOT/tools/pack/chips/${LICHEE_CHIP}/hal/gpu/fbdev/lib/* $AW_LICHEE_ROOT/out/${LICHEE_CHIP}/linux/common/buildroot/target/usr/lib/ -rf
	cp $AW_LICHEE_ROOT/tools/pack/chips/${LICHEE_CHIP}/hal/gpu/fbdev/bin/* $AW_LICHEE_ROOT/out/${LICHEE_CHIP}/linux/common/buildroot/target/bin/ -rf
}

function makecleanall
{
	cd $QT_BUILD_ROOT
	make distclean
	make -C $QT_BUILD_ROOT clean
	rm -rf $QT_INSTALL_DIR
	rm -rf $AW_LICHEE_ROOT/out/${LICHEE_CHIP}/linux/common/buildroot/target/usr/local/$AW_QT_INSTALL_DIR	
}

2.2.添加OPENGL_ES2路径

qtbase\mkspecs\linux-arm-gnueabi-g++\qmake.conf 添加以下定义:
QMAKE_CFLAGS QMAKE_CXXFLAGS QMAKE_INCDIR_OPENGL_ES2 QMAKE_LIBDIR_OPENGL_ES2 QMAKE_LIBS_OPENGL_ES2

示例:

# modifications to g++.conf
QMAKE_CC                = arm-linux-gnueabi-gcc
QMAKE_CXX               = arm-linux-gnueabi-g++
QMAKE_LINK              = arm-linux-gnueabi-g++
QMAKE_LINK_SHLIB        = arm-linux-gnueabi-g++
QMAKE_CFLAGS +=-mfpu=neon -marm -mcpu=cortex-a7
QMAKE_CXXFLAGS +=-mfpu=neon -marm -mcpu=cortex-a7
# modifications to linux.conf
QMAKE_AR                = arm-linux-gnueabi-ar cqs
QMAKE_OBJCOPY           = arm-linux-gnueabi-objcopy
QMAKE_NM                = arm-linux-gnueabi-nm -P
QMAKE_STRIP             = arm-linux-gnueabi-strip
QMAKE_INCDIR_OPENGL_ES2 += $$PWD/../../../../../../tools/pack/chips/sun8iw17p1/hal/gpu/fbdev/include
QMAKE_LIBDIR_OPENGL_ES2 += $$PWD/../../../../../../tools/pack/chips/sun8iw17p1/hal/gpu/fbdev/lib
QMAKE_LIBS_OPENGL_ES2 += -lGLESv2
load(qt_config)

2.3.更换EGL头文件
用t7linux-auto\tools\pack\chips\sun8iw17p1\hal\gpu\fbdev\include\EGL,将qtbase\src\3rdparty\angle\include\EGL中头文件替换。
包含eglplatform.h新增文件。

2.4.编译QT库
运行

$ . ./setenvs512.sh 
$ makeconfig
$ makeall
$ makeinstall

之后会在:

$AW_LICHEE_ROOT/out/${LICHEE_CHIP}/linux/common/buildroot/target/usr/local/$AW_QT_INSTALL_DIR

目录安装QT库文件。

2.5.应用编译
buildroot-201611\target\user_rootfs_build.sh脚本:

1.检测QT版本是否被设置,确认有设置后才往下编译QT应用。否则代表不编译QT。

if [ ! -n "$AWQT_VERSION" ]; then
 echo "error,AWQT_VERSION is empty"
 exit 0
fi

2.检测QT库是否被正常编译安装:

if [ -d "${LICHEE_BR_DIR}/dl/qt-everywhere-opensource-src-${AWQT_VERSION}/Qt-${AWQT_VERSION}/bin/" ];then
(
if [ -d "${USR_TARGET_DIR}/usr/local/Qt-${AWQT_VERSION}/lib" ]; then
#    cp -rf ${USER_MISC}/sdk/fonts ${USR_TARGET_DIR}/usr/local/Qt-5.9.0/lib/
	(cd ${USR_TARGET_DIR}/usr/local/Qt-${AWQT_VERSION}/lib
	rm *.a *.la 
	rm cmake -rf
	)
fi
)
else
echo "you must compile QT${AWQT_VERSION} first!!!!!!!"
sleep 2
fi

3.misc_config
misc_config中设定的AWQT_VERSION版本,是为QT应用编译时使用。
否则退出comp_qtLib-512_only.sh后,AWQT_VERSION失效,无法单独编译QT应用。

3.运行配置
新建:buildroot-201611\target\user_rootfs_extra\qt5.12.sh

export  QTDIR=/usr/local/Qt-5.12.5/
export  QT_ROOT=$QTDIR
export  PATH=$QTDIR/bin:$PATH

export  LD_LIBRARY_PATH=$QTDIR/lib:/usr/lib/cedarx/:$LD_LIBRARY_PATH

export QT_QPA_PLATFORM_PLUGIN_PATH=$QT_ROOT/plugins
export QT_QPA_PLATFORM=linuxfb:tty=/dev/fb0
export QT_QPA_FONTDIR=$QT_ROOT/lib/fonts
#export LD_PRELOAD=/usr/lib/libts.so
#/usr/lib/preloadable_libiconv.so:

TouchDevice=gslX680
for InputDevices in /sys/class/input/input*
do
    DeviceName=`cat $InputDevices/name`
    #echo $InputDevices name:$DeviceName
    if [ $DeviceName == $TouchDevice ];then
	   TouchDeviceNum=${InputDevices##*input}
	   export QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=/dev/input/event$TouchDeviceNum
	   echo "add "/dev/input/event$TouchDeviceNum "to Qt Application."
	   break
	fi
done
if [ ! -n "$TouchDeviceNum" ]; then
 echo "Error:Input device $TouchDevice can not be found,plz check it!"
fi

export QT_QPA_PLATFORM=eglfs
#export QT_QPA_GENERIC_PLUGINS=tslib
export QT_QPA_GENERIC_PLUGINS=evdevtouch
export QT_QPA_EGLFS_INTEGRATION=eglfs_mali
#export QT_QPA_FB_HIDECURSOR=1
#export QT_QPA_EGLFS_HIDECURSOR=1
#export QT_QPA_EGLFS_ROTATION=90
export QWS_MOUSE_PROTO=
export DBUS_SESSION_BUS_ADDRESS=`cat /tmp/dbusaddr`

开机后,先运行该脚本,再启动应用。
4.问题记录
4.1.新电脑常见:在全新环境中QT编译失败
编译后没有Qt库和相关应用。
手动进入buildroot-201611/dl/qt-everywhere-opensource-src-XXX目录,运行. ./setenvs597.sh,之后运行makeconfig,出现如下提示:

cc1plus: error: unrecognized command line option "-std=c++11"
make: *** [project.o] Error 1

该问题为本地gcc(注意是本地gcc,不是交叉编译链)版本不对,请确保编译服务器gcc在4.8以上。
l

inux01@Exdroid11:~$ gcc --version
gcc (Ubuntu/Linaro 4.4.7-8ubuntu1) 4.4.7
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

此时请重新配置gcc,将其指向新版本:

/home/other/gcc/g++ -> /usr/bin/g++-4.8
/home/other/gcc/gcc -> /usr/bin/gcc-4.8

配置新版本的gcc和g++,导出变量:

export PATH=/home/other/gcc/:$PATH

4.2. 编译配置报错

ERROR: The OpenGL functionality tests failed!
You might need to modify the include and library search paths by editing QMAKE_INCDIR_OPENGL[_ES2],
QMAKE_LIBDIR_OPENGL[_ES2] and QMAKE_LIBS_OPENGL[_ES2] in the mkspec for your platform.

qtbase\mkspecs\linux-arm-gnueabi-g++\qmake.conf 添加以下定义:

QMAKE_CFLAGS QMAKE_CXXFLAGS QMAKE_INCDIR_OPENGL_ES2 QMAKE_LIBDIR_OPENGL_ES2 QMAKE_LIBS_OPENGL_ES2

4.3.Egl报错

ERROR: The OpenGL functionality tests failed!
You might need to modify the include and library search paths by editing QMAKE_INCDIR_OPENGL[_ES2],
QMAKE_LIBDIR_OPENGL[_ES2] and QMAKE_LIBS_OPENGL[_ES2] in the mkspec for your platform.

用t7linux-auto\tools\pack\chips\sun8iw17p1\hal\gpu\fbdev\include\EGL,将qtbase\src\3rdparty\angle\include\EGL中文件替换。
包含eglplatform.h这些新增文件。
如果没有设置正确,EGL检测会失败,在配置结果上面可以看到EGL和EGLFS没有设置正确,无法生成Makefile。

...
test config.qtbase_gui.libraries.egl FAILED
...
  EGL .................................... no
  OpenVG ................................. no
  OpenGL:
    Desktop OpenGL ....................... no
    OpenGL ES 2.0 ........................ yes
    OpenGL ES 3.0 ........................ no
    OpenGL ES 3.1 ........................ no
    OpenGL ES 3.2 ........................ no

4.4.libGLESv2.so运行路径错误
运行应用提示:

error while loading shared libraries: /home/XXX/t7linux-auto/out/sun8iw17p1/linux/common/buildroot/host/usr/arm-buildroot-linux-gnueabi/sysroot/lib/libGLESv2.so 
: cannot open shared object file: No such file or directory

查看程序依赖库libGLESv2.so携带了编译路径:

:readelf -d demo

Dynamic section at offset 0x49640 contains 35 entries:
  标记        类型                         名称/值
 0x00000001 (NEEDED)                     共享库:[libQt5Widgets.so.5]
 0x00000001 (NEEDED)                     共享库:[libQt5Gui.so.5]
 0x00000001 (NEEDED)                     共享库:[libQt5Core.so.5]
 0x00000001 (NEEDED)                     共享库:[/home/XXX/t7linux-auto/out/sun8iw17p1/linux/common/buildroot/host/usr/arm-buildroot-linux-gnueabi/sysroot/lib/libGLESv2.so]

qtbase/src/gui/qtgui-config.pri文件中被赋值了路径,没有找到配置点,于是手动删除对应变量。

sed -i '/^QMAKE_LIBS_OPENGL_ES2*/d' qtbase/src/gui/qtgui-config.pri
	sed -i '/^QMAKE_LIBS_EGL*/d' qtbase/src/gui/qtgui-config.pri

该问题卡住了很久,详细处理过程:
1.将libGLESv2放入QT源文件Lib,之后再编译,查看是否带路径。

带路径

2.在QMAKE_LIBDIR_OPENGL_ES2之前添加-L,在查看是都带路径。
提示报错

3.只更换EGL头文件,不添加OPENGL_ES2路径,失败。
自动携带
/home/aero/t7linux-auto/out/sun8iw17p1/linux/common/buildroot/host/usr/arm-buildroot-linux-gnueabi/sysroot/lib/libGLESv2.so
一样运行报错。

4.修改makefile

LIBS          = $(SUBLIBS) /home/aero/t7linux-auto/buildroot-201611/dl/qt-everywhere-src-5.12.5-include-only/qttools/lib/libQt5UiTools.a /home/aero/t7linux-auto/buildroot-201611/dl/qt-everywhere-src-5.12.5-include-only/qtbase/lib/libQt5Widgets.so /home/aero/t7linux-auto/buildroot-201611/dl/qt-everywhere-src-5.12.5-include-only/qtbase/lib/libQt5Gui.so /home/aero/t7linux-auto/buildroot-201611/dl/qt-everywhere-src-5.12.5-include-only/qtbase/lib/libQt5Core.so /home/aero/t7linux-auto/out/sun8iw17p1/linux/common/buildroot/host/usr/arm-buildroot-linux-gnueabi/sysroot/lib/libGLESv2.so -lpthread   

修改为:

LIBS          = $(SUBLIBS) /home/aero/t7linux-auto/buildroot-201611/dl/qt-everywhere-src-5.12.5-include-only/qttools/lib/libQt5UiTools.a /home/aero/t7linux-auto/buildroot-201611/dl/qt-everywhere-src-5.12.5-include-only/qtbase/lib/libQt5Widgets.so /home/aero/t7linux-auto/buildroot-201611/dl/qt-everywhere-src-5.12.5-include-only/qtbase/lib/libQt5Gui.so /home/aero/t7linux-auto/buildroot-201611/dl/qt-everywhere-src-5.12.5-include-only/qtbase/lib/libQt5Core.so /home/aero/t7linux-auto/buildroot-201611/dl/qt-everywhere-src-5.12.5-include-only/qtbase/lib/libGLESv2.so -lpthread   

并将libGLESv2.so拷贝到对应目录。
编译后一样报错。

5.修改Makefile

LIBS          = $(SUBLIBS) /home/aero/t7linux-auto/buildroot-201611/dl/qt-everywhere-src-5.12.5-include-only/qttools/lib/libQt5UiTools.a /home/aero/t7linux-auto/buildroot-201611/dl/qt-everywhere-src-5.12.5-include-only/qtbase/lib/libQt5Widgets.so /home/aero/t7linux-auto/buildroot-201611/dl/qt-everywhere-src-5.12.5-include-only/qtbase/lib/libQt5Gui.so /home/aero/t7linux-auto/buildroot-201611/dl/qt-everywhere-src-5.12.5-include-only/qtbase/lib/libQt5Core.so /home/aero/t7linux-auto/out/sun8iw17p1/linux/common/buildroot/host/usr/arm-buildroot-linux-gnueabi/sysroot/lib/libGLESv2.so -lpthread   

修改为:

LIBS          = $(SUBLIBS) /home/aero/t7linux-auto/buildroot-201611/dl/qt-everywhere-src-5.12.5-include-only/qttools/lib/libQt5UiTools.a /home/aero/t7linux-auto/buildroot-201611/dl/qt-everywhere-src-5.12.5-include-only/qtbase/lib/libQt5Widgets.so /home/aero/t7linux-auto/buildroot-201611/dl/qt-everywhere-src-5.12.5-include-only/qtbase/lib/libQt5Gui.so /home/aero/t7linux-auto/buildroot-201611/dl/qt-everywhere-src-5.12.5-include-only/qtbase/lib/libQt5Core.so   -L/home/aero/t7linux-auto/buildroot-201611/dl/qt-everywhere-src-5.12.5-include-only/qtbase/lib/ -lGLESv2   

编译后ok:

Dynamic section at offset 0x49640 contains 34 entries:
  标记        类型                         名称/值
 0x00000001 (NEEDED)                     共享库:[libQt5Widgets.so.5]
 0x00000001 (NEEDED)                     共享库:[libQt5Gui.so.5]
 0x00000001 (NEEDED)                     共享库:[libQt5Core.so.5]
 0x00000001 (NEEDED)                     共享库:[libGLESv2.so]
 0x00000001 (NEEDED)                     共享库:[libstdc++.so.6]
 0x00000001 (NEEDED)                     共享库:[libm.so.6]
 0x00000001 (NEEDED)                     共享库:[libgcc_s.so.1]
 0x00000001 (NEEDED)                     共享库:[libc.so.6]

据此,修改qtbase\mkspecs\linux-arm-gnueabi-g++\qmake.conf:

QMAKE_INCDIR_OPENGL_ES2 += $$PWD/../../../../../../tools/pack/chips/sun8iw17p1/hal/gpu/fbdev/include
QMAKE_LIBDIR_OPENGL_ES2 += $$PWD/../../../../../../tools/pack/chips/sun8iw17p1/hal/gpu/fbdev/lib
QMAKE_LIBS_OPENGL_ES2 += -L$$QMAKE_LIBDIR_OPENGL_ES2 -lGLESv2

6.按照以上修改,config不过,提示没有—L…路径:

 arm-linux-gnueabi-g++: error: _-L/home/aero/t7linux-auto/buildroot-201611/dl/qt-everywhere-src-5.12.5-set-path1-2/qtbase/mkspecs/linux-arm-gnueabi-g++/../../../../../../tools/pack/chips/sun8iw17p1/hal/gpu/fbdev/lib: No such file or directory
 make: *** [opengl_es2] 错误 1

7.在-L之后添加空格,隔开:

和上面一样,提示找不到 —-L,

'QMAKE_LIBS_OPENGL_ES2 = /home/aero/t7linux-auto/buildroot-201611/dl/qt-everywhere-src-5.12.5-add-L/qtbase/mkspecs/linux-arm-gnueabi-g++/../../../../../../tools/pack/chips/sun8iw17p1/hal/gpu/fbdev/lib/libGLESv2.so _-L /home/aero/t7linux-auto/buildroot-201611/dl/qt-everywhere-src-5.12.5-add-L/qtbase/mkspecs/linux-arm-gnueabi-g++/../../../../../../tools/pack/chips/sun8iw17p1/hal/gpu/fbdev/lib /home/aero/t7linux-auto/buildroot-201611/dl/qt-everywhere-src-5.12.5-add-L/qtbase/mkspecs/linux-arm-gnueabi-g++/../../../../../../tools/pack/chips/sun8iw17p1/hal/gpu/fbdev/lib/libGLESv2.so'

> arm-linux-gnueabi-g++: error: _-L: No such file or directory
> make: *** [opengl_es2] 错误 1

8.可以看到上面的变量时是有累加的,尝试将其写死

QMAKE_LIBS_OPENGL_ES2 = -lGLESv2

makeconfig之后,一样会有

QMAKE_LIBS_OPENGL_ES2 = /home/aero/t7linux-auto/buildroot-201611/dl/qt-everywhere-src-5.12.5-fixed-eglLib/qtbase/mkspecs/linux-arm-gnueabi-g++/../../../../../../tools/pack/chips/sun8iw17p1/hal/gpu/fbdev/lib/libGLESv2.so'

9.在8的基础上,只写QMAKE_LIBS_OPENGL_ES2,将其余清零:

QMAKE_INCDIR_OPENGL_ES2 = 
QMAKE_LIBDIR_OPENGL_ES2 = 
QMAKE_LIBS_OPENGL_ES2 = -lGLESv2

一样不行。

10.用引号括住,看看是否携带路径:

QMAKE_LIBS_OPENGL_ES2 = “-lGLESv2”

'QMAKE_LIBS_OPENGL_ES2 = /home/aero/t7linux-auto/out/sun8iw17p1/linux/common/buildroot/host/usr/arm-buildroot-linux-gnueabi/sysroot/lib/libGLESv2.so'  

一样不行。

11.对与Makefile的总结:
只要携带了路径,就会编译进代码。

12.使用-rpath

QMAKE_LIBS_OPENGL_ES2 = "-rpath /usr/lib -lGLESv2"

结果:

'QMAKE_LIBS_OPENGL_ES2 = "-rpath /usr/lib -lGLESv2"' 


arm-linux-gnueabi-g++ -c -pipe -mfpu=neon -marm -mcpu=cortex-a7 --sysroot=/home/aero/t7linux-auto/buildroot-201611/dl/qt-everywhere-src-5.12.5-rpath/../../../out/sun8iw17p1/linux/common/buildroot/host/usr/arm-buildroot-linux-gnueabi/sysroot --sysroot=/home/aero/t7linux-auto/buildroot-201611/dl/qt-everywhere-src-5.12.5-rpath/../../../out/sun8iw17p1/linux/common/buildroot/host/usr/arm-buildroot-linux-gnueabi/sysroot -O2 -std=gnu++11 -w -fPIC  -I. -I/home/aero/t7linux-auto/buildroot-201611/dl/qt-everywhere-src-5.12.5-rpath/qtbase/mkspecs/linux-arm-gnueabi-g++ -o main.o main.cpp
> arm-linux-gnueabi-g++ --sysroot=/home/aero/t7linux-auto/buildroot-201611/dl/qt-everywhere-src-5.12.5-rpath/../../../out/sun8iw17p1/linux/common/buildroot/host/usr/arm-buildroot-linux-gnueabi/sysroot --sysroot=/home/aero/t7linux-auto/buildroot-201611/dl/qt-everywhere-src-5.12.5-rpath/../../../out/sun8iw17p1/linux/common/buildroot/host/usr/arm-buildroot-linux-gnueabi/sysroot -Wl,-O1 -o opengl_es2 main.o   -rpath\ /usr/lib\ -lGLESv2   
> arm-linux-gnueabi-g++: error: unrecognized command line option '-rpath /usr/lib -lGLESv2'
> make: *** [opengl_es2] 错误 1
 => source failed verification.
test config.qtbase_gui.libraries.opengl_es2 FAILED

13.在-l前面加上空格

'QMAKE_LIBS_OPENGL_ES2 = " -lGLESv2 "' 
> arm-linux-gnueabi-g++ --sysroot=/home/aero/t7linux-auto/buildroot-201611/dl/qt-everywhere-src-5.12.5-l/../../../out/sun8iw17p1/linux/common/buildroot/host/usr/arm-buildroot-linux-gnueabi/sysroot --sysroot=/home/aero/t7linux-auto/buildroot-201611/dl/qt-everywhere-src-5.12.5-l/../../../out/sun8iw17p1/linux/common/buildroot/host/usr/arm-buildroot-linux-gnueabi/sysroot -Wl,-O1 -o opengl_es2 main.o   \ -lGLESv2\    
> arm-linux-gnueabi-g++: error:  -lGLESv2 : No such file or directory

14.查找赋值路径

搜索到QMAKE_LIBS_OPENGL_ES2在qtbase/src/gui/qtgui-config.pri文件中被赋值了路径。
对比5.9.7是没有的。因此config之后删除相关变量:

sed -i '/^QMAKE_LIBS_OPENGL_ES2*/d' qtbase/src/gui/qtgui-config.pri
sed -i '/^QMAKE_LIBS_EGL*/d' qtbase/src/gui/qtgui-config.pri

测试ok。

4.5.触屏不灵
驱动变更,导致buildroot-201611\target\user_rootfs_extra\qt5.12.shQT触摸参数失效:

if [ -e "/dev/input/event3" ]; then
#       export QWS_MOUSE_PROTO="Tslib:/dev/input/event4"
#	export TSLIB_TSDEVICE=/dev/input/event4
export QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=/dev/input/event3

fi

以上在/dev/input/event3时有效,当设备变更时,导致/dev/input/event3不存在,因此失败。
修改对应脚本:

TouchDevice=gslX680
for InputDevices in /sys/class/input/input*
do
    DeviceName=`cat $InputDevices/name`
    #echo $InputDevices name:$DeviceName
    if [ $DeviceName == $TouchDevice ];then
	   TouchDeviceNum=${InputDevices##*input}
	   export QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=/dev/input/event$TouchDeviceNum
	   echo "add "/dev/input/event$TouchDeviceNum "to Qt Application."
	   break
	fi
done
if [ ! -n "$TouchDeviceNum" ]; then
 echo "Error:Input device $TouchDevice can not be found,plz check it!"
fi

4.6.Qt5.125新增:运行出现ShareOpenGLContexts警告

Attribute Qt::AA_ShareOpenGLContexts must be set before QCoreApplication is created.

在新版的代码中,Qt加入了设置选项的检查,如果ShareOpenGLContexts 设置在应用运行之后,就会出现警告,**部分代码为新增:

void QCoreApplication::setAttribute(Qt::ApplicationAttribute attribute, bool on)
{
    if (on)
        QCoreApplicationPrivate::attribs |= 1 << attribute;
    else
        QCoreApplicationPrivate::attribs &= ~(1 << attribute);
/*#if defined(QT_NO_QOBJECT)
    if (Q_UNLIKELY(qApp)) {
#else
    if (Q_UNLIKELY(QCoreApplicationPrivate::is_app_running)) {
#endif
        switch (attribute) {
            case Qt::AA_EnableHighDpiScaling:
            case Qt::AA_DisableHighDpiScaling:
            case Qt::AA_PluginApplication:
            case Qt::AA_UseDesktopOpenGL:
            case Qt::AA_UseOpenGLES:
            case Qt::AA_UseSoftwareOpenGL:
            case Qt::AA_ShareOpenGLContexts:
#ifdef QT_BOOTSTRAPPED
                qWarning("Attribute %d must be set before QCoreApplication is created.",
                         attribute);
#else
                qWarning("Attribute Qt::%s must be set before QCoreApplication is created.",
                         QMetaEnum::fromType<Qt::ApplicationAttribute>().valueToKey(attribute));
#endif
                break;
            default:
                break;
        }*/
    }
}

处理方法:
修改应用代码,在QCoreApplication之前,调用:
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true);

5.error “Qt requires C++11 support”

5.1.Qt编译报错:

…/…/…/include/QtCore/…/…/src/corelib/global/qglobal.h:1172:1:
warning: identifier ‘nullptr’ is a keyword in C++11 [-Wc++0x-compat]
Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName,
bool *ok=nullptr) Q_DECL_NOEXCEPT; ^ In file included from
…/…/…/include/QtCore/qbasicatomic.h:1:0,
from …/…/…/include/QtCore/…/…/src/corelib/thread/qatomic.h:46,
from …/…/…/include/QtCore/qatomic.h:1,
from …/…/…/include/QtCore/…/…/src/corelib/global/qglobal.h:1210,
from …/…/…/include/QtCore/qglobal.h:1,
from …/…/…/include/QtGui/…/…/src/gui/kernel/qtguiglobal.h:43,
from …/…/…/include/QtGui/qtguiglobal.h:1,
from …/…/…/include/QtWidgets/…/…/src/widgets/kernel/qtwidgetsglobal.h:43,
from …/…/…/include/QtWidgets/qtwidgetsglobal.h:1,
from …/…/…/include/QtWidgets/…/…/src/widgets/kernel/qapplication.h:43,
from …/…/…/include/QtWidgets/qapplication.h:1,
from …/…/…/include/QtWidgets/QApplication:1,
from main.cpp:51: …/…/…/include/QtCore/…/…/src/corelib/thread/qbasicatomic.h:61:4:
error: #error “Qt requires C++11 support” # error “Qt requires C++11
support”

5.2.处理方法1

单个模组可以直接修改pro:

QMAKE_CXXFLAGS += -std=c++11

1
或者直接修改makefile:

CFLAGS        += -std=c++11 
CXXFLAGS      += -std=c++11

5.3.处理方法2

交叉编译配置添加:

qt\qt-everywhere-src-5.12.5\qtbase\mkspecs\linux-aarch64-gnu-g++\qmake.conf

QMAKE_CFLAGS +=-std=c++11
QMAKE_CXXFLAGS +=-std=c++11

修改qmake.conf之后,不需要重新交叉编译Qt库,直接make就可以自动更新这些参数。

6.GPU问题
6.1.GPU测试
Gpu测试程序sunxi_gpu_test,编译:

export PATH=/home/aero/t564/longan/out/gcc-linaro-5.3.1-2016.05-x86_64_aarch64-linux-gnu/bin:$PATH
make CROSS_COMPILE=aarch64-linux-gnu- BUILD=debug  

生成sunxi_gpu_test\out\fbdev-debug-aarch64-linux-gnu-\bin\sunxi_gpu_test
推送至目标平台。
mali-bifrost\fbdev\mali-g31\aarch64-linux-gnu\lib 相关库文件推送至目标平台。

运行sunxi_gpu_test,提示报错。
原因为:

devtmpfs on /dev type devtmpfs (rw,nosuid,relatime,size=427848k,nr_inodes=106962,mode=755)

挂载不成功。

qtbase\mkspecs\linux-arm-gnueabi-g++\qmake.conf 添加以下定义:

QMAKE_CFLAGS +=-DEGL_FBDEV
QMAKE_CXXFLAGS +=-DEGL_FBDEV

# 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_GPU_INC
QMAKE_LIBDIR_OPENGL_ES2 += $$QT_GPU_LIB
QMAKE_LIBS_OPENGL_ES2 += -lGLESv2
load(qt_config)

7.1.更换EGL头文件
用gpu_um_pub\mali-bifrost\fbdev\include\EGL,将qtbase\src\3rdparty\angle\include\EGL中头文件替换。
7.2.配置编译参数

AW_QT_INSTALL_DIR=Qt-5.12.5

PWD=`pwd`

export QT_BUILD_ROOT=$PWD
export QT_INSTALL_DIR=$LICHEE_TOP_DIR/platform/framework/sdk_lib/$AW_QT_INSTALL_DIR
export QT_GPU_LIB=$LICHEE_TOP_DIR/platform/core/graphics/gpu_um_pub/mali-bifrost/fbdev/mali-g31/aarch64-linux-gnu/lib
export QT_GPU_INC=$LICHEE_TOP_DIR/platform/core/graphics/gpu_um_pub/mali-bifrost/include
QT_TARGET_INSTALL=$LICHEE_BR_OUT/target/usr/local/$AW_QT_INSTALL_DIR



####  acturly use
export SYSROOT=$LICHEE_TOP_DIR/out/t507/demo2.0/longan/buildroot/host/usr/aarch64-buildroot-linux-gnu/sysroot
export PATH=$LICHEE_BR_OUT/host/bin/:$PATH
export CROSS_COMPILE=$LICHEE_TOP_DIR/out/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu
export CPLUS_INCLUDE_PATH=$PWD/qtbase/src/3rdparty/angle/include:$CPLUS_INCLUDE_PATH

HOST=aarch64-linux-gnu

OUT_GCC=`find ${LICHEE_BR_OUT} -perm /a+x -a -regex '.*-gcc'`
OUT_CPP=`find ${LICHEE_BR_OUT} -perm /a+x -a -regex '.*-g\+\+'`

export CC=$OUT_GCC
export CXX=$OUT_GCC

cpu_cores=`cat /proc/cpuinfo | grep "processor" | wc -l`
if [ ${cpu_cores} -le 8 ] ; then
	LICHEE_JLEVEL=${cpu_cores}
else
	LICHEE_JLEVEL=${cpu_cores}
fi

env

function cqtroot
{
cd $QT_BUILD_ROOT
}
#-no-c++11
function makeconfig
{
	cp $QT_GPU_LIB/* $SYSROOT/lib/ -rf
	mkdir -p $QT_INSTALL_DIR

	$QT_BUILD_ROOT/configure \
		-opensource \
		-confirm-license \
		-extprefix $QT_INSTALL_DIR \
		-sysroot $SYSROOT \
		-xplatform linux-aarch64-gnu-g++ \
		-device-option CROSS_COMPILE=$CROSS_COMPILE \

8.问题记录
8.1.GPU文件链接
需要将所有库文件最终指向mali.so。
8.2.新增头文件
QT需要读取\fbdev_window.h文件,需要创建一个头文件放在对应目录。否则编译不含mali egl选项,运行会报错。

9.eglfs_mali unsupport
QT移植到T5芯片,生成应用程序运行报错:

> /analogclock qt.qpa.egldeviceintegration: Failed to load EGL device
> integration "eglfs_mali" EGL library doesn't support Emulator
> extensions Aborted

9.1.按照网络搜索,设置:

export QT_QPA_EGLFS_INTEGRATION=none

无效
9.2.设置

export QT_QPA_EGLFS_INTEGRATION=eglfs_mali

无效
9.3.查看配置发现egl有错误:

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 ........................... no
    EGLFS Raspberry Pi ................... no
    EGLFS X11 ............................ no
  LinuxFB ................................ yes
  VNC .................................... yes
  Mir client ............................. no

这里EGLFS Mali … no是不正常的。

9.3.1.追溯配置错误:

Checking for Mali EGL…

qt-everywhere-src-5.12.5-2/config.tests/egl-mali:
qtbase/mkspecs/linux-aarch64-gnu-g++ -o main.o main.cpp
main.cpp:2:10: fatal error: EGL/fbdev_window.h:没有那个文件或目录
#include <EGL/fbdev_window.h>
^~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [main.o] 错误 1

这里需要fbdev_window.h,没找到。
9.3.2.添加fbdev_window.h
再次config。这下显示配置正常了:

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 ............................ no
  LinuxFB ................................ yes
  VNC .................................... yes
  Mir client ............................. no

9.3.3.重新编译
会多生成plugins\egldeviceintegrations\libqeglfs-mali-integration.so这个文件。
9.3.4.问题解决
将该文件推送到目标板,就正常了。

10.Qt fatal error: GLES3/gl3.h: No such file or directory
Qt交叉编译应用后报错:

…/…/…/include/QtGui/…/…/src/gui/opengl/qopengl.h:109:26: fatal error: GLES3/gl3.h: No such file or directory

编译单个应用,我们可以直接填写对应路径来解决,但是这个其实是交叉编译系统配置问题,每一个应用都改会比较麻烦。最佳方式是交叉编译时,就通过统一的配置解决。

10.1.处理方法1:

A:platform\framework\qt\qt-everywhere-src-5.12.5\qtbase\mkspecs\linux-aarch64-gnu-g++\qmake.conf
添加OPENGL_ES2参数:

export QT_GPU_LIB=/platform/core/graphics/gpu_um_pub/mali-bifrost/fbdev/mali-g31/aarch64-linux-gnu/lib
export QT_GPU_INC=/platform/core/graphics/gpu_um_pub/mali-bifrost/include

# 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_GPU_INC
QMAKE_LIBDIR_OPENGL_ES2 += $$QT_GPU_LIB
QMAKE_LIBS_OPENGL_ES2 += -lGLESv2
10.2.处理方法2:

不设置QMAKE_INCDIR_OPENGL_ES2 ,直接放入sysroot目录。
.configure配置时,导出sysroot:

export SYSROOT=out/buildroot/host/usr/aarch64-buildroot-linux-gnu/sysroot

./configure \
		-opensource \
		-confirm-license \
		-extprefix $QT_INSTALL_DIR \
		-sysroot $SYSROOT \
		-xplatform linux-aarch64-gnu-g++ \
		-device-option CROSS_COMPILE=$CROSS_COMPILE \
		...

编译时,直接拷贝头文件到sysroot的usr/include目录:

cp   ${MALI_INC_DIR}/*   out/buildroot/host/usr/aarch64-buildroot-linux-gnu/sysroot/usr/include -rf
  • 6
    点赞
  • 29
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值