开发环境:
Ubuntu 14.04.5 LTS
TARGET: imx6q
Qt: qt-everywhere-opensource-src-5.4.0.tar.gz
下载地址:http://download.qt.io/archive/qt/5.9/5.9.4/single/
gpu: gpu-viv-bin-mx6q-3.10.17-1.0.0.tar.gz
下载地址:http://repository.timesys.com/buildsources/g/gpu-viv-bin-mx6q/
交叉工具: gcc-linaro-5.3-20170216.tar.bz2
来源于公司共享盘【大家可以到linaro官网下载自己需要的交叉编译工具,网址是: http://releases.linaro.org/components/toolchain/binaries/5.3-2016.05/armeb-linux-gnueabihf/,需要注意的是自己的开发板是否支持eabihf,测试方法也非常简单,使用该交叉编译工具链编译一个helloword放到开发板上看是否正常运行即可】
准备工作dbus移植:
原因:非强制指定dbus库,移植出来的qt库可能不稳定,有时候执行报错:
random: 33_widget urandom read with 114 bits of entropy available
This application failed to start because it could not find or load the Qt platform plugin "eglfs"
in "/usr/qt5.9.4/plugins".
Reinstalling the application may fix this problem.
Aborted
强制指定dbus库后一般没出现过上述情况,故需要先进行dbus的移植。
Dbus移植:
工具:expat-2.1.0.tar.gz (dbus编译依赖库)
下载地址:http://sourceforge.net/projects/expat/files/expat/
工具:dbus-1.2.30.tar.gz
下载地址:http://dbus.freedesktop.org/releases/dbus/
1》 tar -xvf expat-2.1.0.tar.gz
cd expat-2.1.0
2》 CC=arm-linux-gnueabihf-gcc ./configure --host=arm-linux --prefix=/opt/EmbedRigol/install-dev/expat-2.1.0
make
make install
3》 tar -xvf dbus-1.2.30.tar.gz
cd dbus-1.2.30
4》 CC=arm-linux-gnueabihf-gcc ./configure CPPFLAGS=-I/opt/EmbedRigol/install-dev/expat-2.1.0/include/ LIBS=-L/opt/EmbedRigol/install-dev/expat-2.1.0/lib --prefix=/opt/EmbedRigol/install-dev/dbus-1.2.30 --host=arm-linux --enable-abstract-sockets
make
make install
QT移植:
1》 mkdir qt5.9.4
cd qt5.9.4
2》 cp xxxx/gpu-viv-bin-mx6q-3.10.17-1.0.0.tar.gz ./
tar -xvf gpu-viv-bin-mx6q-3.10.17-1.0.0.tar.gz
3》 mkdir exlib
cp gpu-viv-bin-mx6q-3.10.17-1.0.0/hardfp/usr ./exlib -r
4》 cp xxxx/qt-everywhere-opensource-src-5.9.4.tar.xz ./
tar -xvf qt-everywhere-opensource-src-5.9.4.tar.xz
mv qt-everywhere-opensource-src-5.9.4 qt-src
5》 cd qtbase/mkspecs/devices/linux-imx6-g++
更改 qmake.conf:
#
# qmake configuration for the Freescale iMX6 boards (single, dual and quad)
#
include(../common/linux_device_pre.conf)
QMAKE_LIBS_EGL += -lEGL -lGAL
QMAKE_LIBS_OPENGL_ES2 += -lGLESv2 -lEGL -lGAL
QMAKE_LIBS_OPENVG += -lOpenVG -lEGL -lGAL
QMAKE_INCDIR_OPENVG = /qt5.9.4/exlib/usr/include
QMAKE_LIBDIR_OPENVG = /qt5.9.4/exlib/usr/lib
IMX6_CFLAGS = -march=armv7-a -mfpu=neon -DLINUX=1 -DEGL_API_FB=1
QMAKE_CFLAGS += $$IMX6_CFLAGS
QMAKE_CXXFLAGS += $$IMX6_CFLAGS
QMAKE_INCDIR_OPENGL_ES2 = /qt5.9.4/exlib/usr/include
QMAKE_LIBDIR_OPENGL_ES2 = /qt5.9.4/exlib/usr/lib
QMAKE_LIBS_OPENGL_ES2 = -lGLESv2 -lEGL -lVDK -lGAL
QMAKE_INCDIR_EGL = /qt5.9.4/exlib/usr/include
QMAKE_LIBDIR_EGL = /qt5.9.4/exlib/usr/lib
DISTRO_OPTS += hard-float
# Preferred eglfs backend
EGLFS_DEVICE_INTEGRATION = eglfs_viv
#指定dbus库
QMAKE_INCDIR += /opt/EmbedRigol/install-dev/dbus-1.2.30/include/dbus-1.0
QMAKE_INCDIR += /opt/EmbedRigol/install-dev/dbus-1.2.30/lib/dbus-1.0/include
QMAKE_LIBDIR += /opt/EmbedRigol/install-dev/dbus-1.2.30/lib
include(../common/linux_arm_device_post.conf)
load(qt_config)
6》 cd /qt5.9.4/qt-src
配置:./configure -v -prefix /qt5.9.4/qt5.9.4 -opensource -confirm-license -qt-sqlite -qt-libpng -qt-libjpeg -qt-freetype -qt-pcre -dbus -no-iconv -device imx6 -no-xcb -no-directfb -linuxfb -no-kms -eglfs -qpa eglfs -opengl es2 -device-option CROSS_COMPILE=arm-linux-gnueabihf- -make examples
make -j2
make install
7》拷贝库
cp /qt5.9.4/exlib/usr/lib/* /qt5.9.4/qt5.9.4/lib/ -r
cp /opt/EmbedRigol/install-dev/dbus-1.2.30/lib/* /qt5.9.4/qt5.9.4/lib/ -r
8》拷贝/qt5.9.4/qt5.9.4到根文件系统的/usr/
9》开发板环境变量配置:
vi /etc/profile
export QT_ROOT=/usr/qt5.9.4
export LD_LIBRARY_PATH=/lib:/usr/lib:$QT_ROOT/lib
export QT_QPA_PLATFORM_PLUGIN_PATH=$QT_ROOT/plugins
export QT_QPA_PLATFORM=eglfs
export QT_QPA_EGLFS_FB=/dev/fb1
export FB_MULTI_BUFFER=2
export QT_QPA_EGLFS_PHYSICAL_WIDTH=480
export QT_QPA_EGLFS_PHYSICAL_HEIGHT=480
export QT_QPA_EGLFS_WIDTH=480
export QT_QPA_EGLFS_HEIGHT=640
export QT_QPA_FONTDIR=$QT_ROOT/lib/fonts
export QML2_IMPORT_PATH=$QT_ROOT/qml
10》source /etc/profile