运行平台:OKMX6DL-C
编译平台:Ubuntu 14.04.6 LTS
编译工具:arm-poky-linux-gnueabi-gcc(gcc version 5.3.0 (GCC) )
qt源码:qt-everywhere-opensource-src-5.9.6.tar.xz
参考:
嵌入式开发之Qt-5.9.6交叉编译(带WebEngine)
QT官网关于交叉编译说明
g++: internal compiler error: Killed (program cc1plus) 解决办法
第4篇 交叉编译Qt 5.4.0
安装 SDK:
资料:飞凌开发板提供的OKMX6X-C_Linux4.1.15 用户资料Linux工具fsl-imx-x11-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.1.15-2.1.0.sh
(1)将fsl-imx-x11-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.1.15-2.1.0.sh拷贝到虚拟机任意目录 ,执行:
./fsl-imx-x11-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.1.15-2.1.0.sh
默认将会安装到/opt/fsl-imx-x11/目录下(这里安装到了/opt/fsl-imx-x11/4.1.15-2.1.0/)。
安装完成后 /opt/fsl-imx-x11/4.1.15-2.1.0/ 目录结构如下:
lin@ubuntu:/opt/lin$ ls
environment-setup-cortexa9hf-neon-poky-linux-gnueabisite-config-cortexa9hf-neon-poky-linux-gnueabi
sysroots
version-cortexa9hf-neon-poky-linux-gnueabi
environment-setup-cortexa9hf-neon-poky-linux-gnueabisite-config-cortexa9hf-neon-poky-linux-gnueabi 是环境初始化脚本。
(2)环境变量(注意空格):
. /opt/lin/environment-setup-cortexa9hf-neon-poky-linux-gnueabisite-config-cortexa9hf-neon-poky-linux-gnueabi
(3)译器是否安装成功:
arm-poky-linux-gnueabi-gcc -v
安装依赖库
sudo apt-get install gcc-multilib g+±multilib
sudo apt install pkg-config
sudo apt install pkgconf
解压qt源码
$ xz -d qt-everywhere-opensource-src-5.9.6.tar.xz #解压文件
$ tar xvf qt-everywhere-opensource-src-5.9.6.tar
删除旧版Qt
需要着重注意sysroot对应的cortexa9hf-neon-poky-linux-gnueabi目录下存在之前编译的旧Qt版本的动态库,必须进行清除操作,否则将会影响新版本Qt的编译。
cd /opt/lin/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib$
sudo rm .libQt* -rf
sudo rm lib/qt5 -rf
创建配置脚本
#!/bin/bash
sudo ./configure -v -opensource -confirm-license -sysroot /opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi -no-gcc-sysroot -prefix /usr/local/Qt-5.9.6 -device linux-imx6-g++ -device-option CROSS_COMPILE=/opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi- -release -shared -make libs -verbose -no-pch -no-rpath -pkg-config -accessibility -no-alsa -icu -dbus -no-glib -no-directfb -eglfs -no-kms -linuxfb -xcb -xcb-xlib -evdev -no-libinput -xinput2 -no-tslib -libudev -no-mtdev -nomake examples -nomake tests -fontconfig -no-opengl -opengl es2 -egl -no-openvg -system-zlib -system-libjpeg -system-libpng -system-xcb -openssl-linked -qt-pcre -pulseaudio -no-sm -no-sql-db2 -no-sql-ibase -no-sql-mysql -no-sql-oci -no-sql-odbc -no-sql-psql -no-sql-sqlite2 -no-sql-tds -widgets -xkb
修改qtbase/mkspecs/devices/linux-imx6-g++/qmake.conf
#
# qmake configuration for the Freescale iMX6 boards (single, dual and quad)
#
# The configuration below is set up for running with EGL on the framebuffer via
# the eglfs platform plugin and its eglfs_viv backend.# Wayland is also fully functional out of the box. However, when writing Wayland
# *compositors* with Qt, the eglfs backend will have to be switched to
# eglfs_viv_wl by setting the QT_QPA_EGLFS_INTEGRATION environment variable.
#
# Below is an example configure line that assumes the SDK is in
# $HOME/imx6/toolchain. On device Qt is expected to be placed under
# /usr/local/qt5 whereas on the host 'make install' will copy the host tools and
# the target libraries to $HOME/imx6/qt5.
#
# ./configure -prefix /usr/local/qt5 -extprefix $HOME/imx6/qt5 -device linux-imx6-g++
# -device-option CROSS_COMPILE=$HOME/imx6/toolchain/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-
# -sysroot $HOME/imx6/toolchain/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi
# -nomake examples -nomake tests -v
#include(../common/linux_device_pre.conf)QMAKE_LIBS_EGL += -lEGL
QMAKE_LIBS_OPENGL_ES2 += -lGLESv2 -lEGL -lGAL
QMAKE_LIBS_OPENVG += -lOpenVG -lEGL -lGALIMX6_CFLAGS = -march=armv7-a -mfpu=neon -DLINUX=1 -DEGL_API_FB=1
QMAKE_CFLAGS += $$IMX6_CFLAGS
QMAKE_CXXFLAGS += $$IMX6_CFLAGSDISTRO_OPTS += hard-floatDBUS_LIBS = -L/opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib-ldbus-1# Preferred eglfs backend
EGLFS_DEVICE_INTEGRATION = eglfs_vivQMAKE_INCDIR_OPENGL_ES2 = /home/l/workspace/imx6/tools/gpu-viv-bin-mx6q-3.10.17-1.0.2/hardfp/usr/include
QMAKE_LIBDIR_OPENGL_ES2 = /home/l/workspace/imx6/tools/gpu-viv-bin-mx6q-3.10.17-1.0.2/hardfp/usr/lib
QMAKE_INCDIR_EGL = /home/l/workspace/imx6/tools/gpu-viv-bin-mx6q-3.10.17-1.0.2/hardfp/usr/include
QMAKE_LIBDIR_EGL = /home/l/workspace/imx6/tools/gpu-viv-bin-mx6q-3.10.17-1.0.2/hardfp/usr/libinclude(../common/linux_arm_device_post.conf)# modifications to g++.conf
QMAKE_CC = /opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc -march=armv7-a -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi
QMAKE_CXX = /opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++ -march=armv7-a -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi
QMAKE_LINK = /opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++ --sysroot=/opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi
QMAKE_LINK_SHLIB = /opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++ --sysroot= /opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi# modifications to linux.conf
QMAKE_AR = /opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-ar cqs
QMAKE_OBJCOPY = /opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-objcopy
QMAKE_NM = /opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-nm -P
QMAKE_STRIP = /opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-stripload(qt_config)
gpu库
至此EGLFS i.Mx6的支持是无法开启的,原因为sysroot中的EGL依赖库不是GPU版本,必须使用官方提供的GPU版本。gpu-viv-bin-mx6q-3.10.17-1.0.0.tar.gz
tar xvzf gpu-viv-bin-mx6q-3.10.17-1.0.0.tar.gz
解压完成后进入gpu-viv-bin-mx6q-3.10.17-1.0.0目录,该目录中有以下内容: 其中hardfp中的内容是我们需要的。把hardfp目录下的usr/lib/和include文件替换sysroot目录下的usr/lib 和usr/include中的文件,此目录是自己定义的,读者可以拷贝到其它目录下,只需要在后边修改Qt的编译配置文件的时候设置正确就可以了。~
sudo make
许久之后。。。
好久好久以后。。。
sudo make install