FriendlyARM 4412开发板自带了Mali400 GPU,将QT5.6.0交叉编译到ARM-A9上,步骤如下所述。
1、下载QT5.6.0的源码包qt-everywhere-opensource-src-5.6.0.tar.gz。
2、解压源码包
tar zxvf qt-everywhere-opensource-src-5.6.0.tar.gz
3、运行.configure进行配置如下
./configure -release -opensource -confirm-license -plugin-sql-sqlite -xplatform linux-arm-gnueabi-g++ -nomake examples -no-dbus -no-c++11 -no-tslib -qt-libjpeg -qt-libpng -qt-zlib -prefix /usr/local/Trolltech/Qt-5.6.0-ARM-4412/ -opengl es2 -v -eglfs -pkg-config4、修改编译配置文件,在目录:qt-everywhere-opensource-src-5.6.0/qtbase/mkspecs/linux-arm-gnueabi-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
QMAKE_CFLAGS_RELEASE += -O2 -march=armv7-a #cortex-A9
QMAKE_CXXFLAGS_RELEASE += -O2 -march=armv7-a
include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)
# modifications to g++.conf
QMAKE_CC = /source/opt/FriendlyARM/toolschain/4.5.1/bin/arm-linux-gcc
QMAKE_CXX = /source/opt/FriendlyARM/toolschain/4.5.1/bin/arm-linux-g++
QMAKE_LINK = /source/opt/FriendlyARM/toolschain/4.5.1/bin/arm-linux-g++
#QMAKE_LINK +=/source/opt/FriendlyARM/toolschain/4.5.1/arm-none-linux-gnueabi/sys-root/usr/lib
QMAKE_LINK_SHLIB = /source/opt/FriendlyARM/toolschain/4.5.1/bin/arm-linux-g++
# modifications to linux.conf
QMAKE_AR = /source/opt/FriendlyARM/toolschain/4.5.1/bin/arm-linux-ar cqs
QMAKE_OBJCOPY = /source/opt/FriendlyARM/toolschain/4.5.1/bin/arm-linux-objcopy
QMAKE_NM = /source/opt/FriendlyARM/toolschain/4.5.1/bin/arm-linux-nm -P
QMAKE_STRIP = /source/opt/FriendlyARM/toolschain/4.5.1/bin/arm-linux-strip
GPU_HEADER_INCLUDE = /home/nisp/rootfs_qtopia_qt4/usr/include/khronos/
GPU_HEADER_LIB = /home/nisp/rootfs_qtopia_qt4/lib/
GPU_HEADER_LIB += /home/nisp/rootfs_qtopia_qt4/usr/lib/
QMAKE_INCDIR_OPENGL_ES2 = $$GPU_HEADER_INCLUDE/GLES2/
QMAKE_INCDIR_OPENGL_ES2 += $$GPU_HEADER_INCLUDE/
QMAKE_LIBDIR_OPENGL_ES2 = $$GPU_HEADER_LIB
QMAKE_LIBS_OPENGL_ES2 = -lEGL -lGLESv2 -lGLESv1_CM -lMali
QMAKE_LIBDIR_OPENGL = $$GPU_HEADER_INCLUDE/GLES
#QMAKE_LIBDIR_OPENGL_QT = $$SGX_SDK_ROOT/gfx_relg_es8.x
QMAKE_LIBS_OPENGL_ES1 = -lEGL -lGLES_CM -lMali
QMAKE_INCDIR_OPENVG = $$GPU_HEADER_INCLUDE/VG/
QMAKE_LIBDIR_OPENVG = $$GPU_HEADER_LIB
QMAKE_LIBS_OPENVG = -lEGL -lGLESv2 -lGLESv1_CM -lOpenVG -lOpenVGU -lMali
QMAKE_INCDIR_EGL = $$GPU_HEADER_INCLUDE/EGL/
#QMAKE_INCDIR_POWERVR = $$QT_INSTALL_DIR/src/3rdparty/powervr/wsegl2
QMAKE_LIBDIR_EGL = $$GPU_HEADER_LIB
QMAKE_LIBS_EGL = -lEGL -lGLESv2 -lGLESv1_CM -lMali
#QMAKE_INCDIR += $$TSLIB_INCDIR
QMAKE_INCDIR += $$QMAKE_INCDIR_OPENGL_ES2
QMAKE_LIBDIR += $$QMAKE_LIBDIR_OPENGL_ES2
#QMAKE_LIBDIR += $$TSLIB_LIBDIR
QMAKE_LIBS = $$QMAKE_LIBS_OPENGL_ES2
QMAKE_DEFAULT_LIBDIRS += /home/nisp/rootfs_qtopia_qt4/lib/
QMAKE_DEFAULT_LIBDIRS += /source/opt/FriendlyARM/toolschain/4.5.1/arm-none-linux-gnueabi/sys-root/usr/lib
load(qt_config)
5、编译
make
执行make期间出现error,“undefined reference to `__sync_sub_and_fetch_4'”,为解决这个问题,执行以下操作:
(1)下载了gcc-4.4.3,解压,在gcc-4.4.3/gcc/config/arm/目录下找到一个linux-atomic.c;
(2)制作链接库:使用libtool制作,输入命令
libtool --tag=CC --mode=compile arm-linux-gcc -g -O2 -MT linux-atomic.lo -MD -MP -MF linux-atomic.Tpo -c -o linux-atomic.lo linux-atomic.c
然后:
libtool --tag=CC --mode=link arm-linux-g++ -g -O2 -o liblinux-atomic.la linux-atomic.lo
这一步会在当前目录生成.libs目录;
(3)将生成的库拷贝到一个比较短的目录,比如/opt:
cp .libs/liblinux-atomic.a /opt
(4)修改Qt的Makefile:
进入Qt源码目录:
cd qt-everywhere-opensource-src-5.6.0
然后:
vim qtscript/src/script/Makefile
修改:
在LIBS = 。。。。。。。。。。。。。的结尾添加 -L/opt -llinux-atomic
保存,继续make,就OK了。
解决这个bug参考了以下链接:
http://blog.csdn.net/wangmingape/article/details/24545775
6、安装
sudo make install
至此,交叉编译完成。
7、拷贝库到目标板文件系统
将/usr/local/Trolltech/Qt-5.6.0-ARM/下的lib和plugins拷贝到目标板文件系统。
8、开发板上QT5.6.0的环境变量配置如下:
export QTDIR=/opt/Qtopia5.6.0
export PATH=$QTDIR/bin:/usr/bin:$PATH
export LD_LIBRARY_PATH=$QTDIR/lib:/usr/local/lib:/lib:$LD_LIBRARY_PATH
export QT_QPA_PLATFORM_PLUGIN_PATH=/opt/Qtopia5.6.0/plugins/platforms
export QT_QPA_PLATFORM=eglfs
export QT_QPA_FONTDIR=/opt/Qtopia5.6.0/lib/fonts
#export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0:size=1200x800:mmsize=95x150:offset=0x0
export QT_DEBUG_PLUGINS=1
export QT_QPA_EGLFS_DEBUG=1
export QML2_IMPORT_PATH=$QTDIR/qml
export QML_IMPORT_PATH=$QTDIR/qml
export QT_PLUGIN_PATH=$QTDIR/plugins