im6q移植QT5.5.1

三种QT移植的思路:

一、基于gcc交叉编译工具链的简单移植
工具:gcc-linaro-5.3-20170216.tar.bz2
工具来源:来自公司的共享盘,网上的话没有认真找,但是发现一个很好的网站:http://www.veryarm.com/,感觉非常不错。
该交叉编译工具链中已经有QT移植好的库级支持文件:
1》解压该工具链
2》进入到工具链的:/opt/EmbedSky/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/qt5.5/rootfs_imx6q_V3_qt5.5_env/目录
目录下有lib   qt5.5_env   usr三个目录
3》将lib目录下的东西扩充到开发板的lib目录下
4》将qt5.5_env整个目录放到开发板usr/目录下
5》将usr/lib/目录下的所有东西扩充到开发板lib目录下
6》执行QT程序发现提示错误
QML debugging is enabled. Only use this in a safe environment.
This application failed to start because it could not find or load the Qt platform plugin "xcb".
Available platform plugins are: eglfs, minimal, minimalegl, offscreen.
Reinstalling the application may fix this problem.
Aborted
这个是因为环境变量没有设置,需指定显示插件。
6》开发板设置环境变量
vi    /etc/profile
在文件最后面追加:
export QT_ROOT=/usr/qt5.5
export LD_LIBRARY_PATH=/lib:/usr/lib:$QT_ROOT/lib
export QT_QPA_PLATFORM_PLUGIN_PATH=$QT_ROOT/plugins
export QT_QPA_PLATFORM=eglfs:tty=/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
7》执行QT程序发现提示错误
process 85: D-Bus library appears to be incorrectly set up; failed to read machine uuid: Failed to
open “/etc/machine-id”: No such file or directory
See the manual page for dbus-uuidgen to correct this issue.
D-bus not built with -rdynamic so unable to print abacktrace
Aborted
8》解决上面这个错误可以通过:
cd   /etc/
mkdir   machine-id
dbus-uuidgen > /etc/machine-id
但是在bin目录下并没有发现dbus-uuidgen 工具,所以还需要进行该工具的移植
dbus的具体移植情况参见dbus-1.2.30移植.txt
二、基于QT源码的移植
移植过程:
A、移植expat库和dbus库
工具:dbus-1.2.30
下载地址:
http://dbus.freedesktop.org/releases/dbus/
1》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
2》make
3》make install
首次进行编译配置的时候可能会报错:这是因为缺少expat库的支持
configure: error: Could not find expat.h, check config.log for failed attempts
解决:交叉编译expat
工具:expat-2.1.0 
下载地址:
http://sourceforge.net/projects/expat/files/expat/ 
1》CC=arm-linux-gnueabihf-gcc ./configure --host=arm-linux --prefix=/opt/EmbedRigol/install-dev/expat-2.1.0
2》make 
3》make install
再返回dbus源码顶层目录执行命令。
dbus简单介绍:
D-Bus是一种高级的进程间通信机制,它由freedesktop.org项目提供,使用GPL许可证发行。D-Bus最主要的用途是在Linux桌面环境为进程提供通信,同时能将Linux桌面环境和Linux内核事件作为消息传递到进程。D-Bus的主要概念为总线,注册后的进程可通过总线接收或传递消息,进程也可注册后等待内核事件响应,例如等待网络状态的转变或者计算机发出关机指令。目前,D-Bus已被大多数Linux发行版所采用,开发者可使用D-Bus实现各种复杂的进程间通信任务。
expat简单介绍:

Expat是一个面向流的解析器。您注册的解析器回调(或handler)功能,然后开始搜索它的文档。当解析器识别该文件的指定的位置,它会调用该部分相应的处理程序(如果您已经注册的一个)。该文件被输送到解析器,会被分割成多个片断,并分段装到内存中。因此expat可以解析那些巨大的文件。


B、配置编译QT源码
工具:
gpu-viv-bin-mx6q-3.10.17-1.0.0.tar.gz    ------------------------为OPENGL提供硬件相关库支持,之所以需要OPENGL是因为要使用Quick就需要使用到OPENGL
下载地址:http://repository.timesys.com/buildsources/g/gpu-viv-bin-mx6q/
qt-everywhere-opensource-src-5.5.1.tar.gz
下载地址:http://download.qt.io/archive/qt/5.5/5.5.1/single/
1》cd  /opt
2》mkdir  qt-5.5
3》mkdir  exlib
4》tar -xvf  gpu-viv-bin-mx6q-3.10.17-1.0.0.tar.gz 
5》tar -xvf  qt-everywhere-opensource-src-5.5.1.tar.gz
6》cp   ./gpu-viv-bin-mx6q-3.0.35-4.0.0/hardfp/hardfp/usr      ./exlib   -r
7》mv   qt-everywhere-opensource-src-5.5.1    qt_src
8》cd   /opt/qt-5.5/qt_src/qtbase/mkspecs/devices/linux-imx6-g++
9》更改/opt/qt-5.5/qt_src/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    = /opt/qt-5.5/exlib/usr/include
QMAKE_LIBDIR_OPENVG    = /opt/qt-5.5/exlib/usr/lib
IMX6_CFLAGS             = -march=armv7-a -mfpu=neon -DLINUX=1 -DEGL_API_FB=1
QMAKE_CFLAGS           += $$IMX6_CFLAGS
QMAKE_CXXFLAGS         += $$IMX6_CFLAGS
####################################指定GPU相关库#####################################
QMAKE_INCDIR_OPENGL_ES2 = /opt/qt-5.5/exlib/usr/include
QMAKE_LIBDIR_OPENGL_ES2 = /opt/qt-5.5/exlib/usr/lib
QMAKE_LIBS_OPENGL_ES2   = -lGLESv2 -lEGL -lVDK -lGAL
QMAKE_INCDIR_EGL = /opt/qt-5.5/exlib/usr/include
QMAKE_LIBDIR_EGL = /opt/qt-5.5/exlib/usr/lib
DISTRO_OPTS += hard-float
# Preferred eglfs backend
#EGLFS_DEVICE_INTEGRATION = eglfs_viv
#################指定dbus库为开始编译的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)
10》手动强制指定EGL为yes:vi  qt_src/qtbase/configure
修改第5634行左右的:
if compileTest qpa/eglfs-viv "eglfs-viv"; then
            CFG_EGLFS_VIV=yes
        else
            CFG_EGLFS_VIV=yes    //源文件中是CFG_EGLFS_VIV=no  强制改为yes
11》配置:./configure -v -prefix /opt/qt-arm-5.5.1 -opensource -confirm-license -qt-sql-sqlite -qt-libpng -qt-libjpeg -qt-freetype -qt-pcre -device imx6 -no-xcb -no-directfb -linuxfb -no-kms -eglfs -qpa  -dbus eglfs -opengl es2 -device-option CROSS_COMPILE=arm-linux-gnueabihf- -make examples
12》编译:make
13》输出到指定目录:make  install
14》集中库:
分别将编译生成的dbus相应的库和exlib/usr中对应的库都拷贝到生的qt-arm-5.5.1/lib目录,如果由相应的include文件建议也分别对应拷贝到qt-arm-5.5.1对应的目录下
15》将qt-arm-5.5.1文件拷贝到开发板根文件系统的/usr/下更名为qt5.5
16》设置开发板的环境变量
vi  /etc/profile
在其下添加:(这里我自己的配置是指定使用linuxfb作为显示插件,在编译的时候同时勾选了eglfs显示插件,按照道理应该也是可以用的,这里没有测试)
export QT_ROOT=/usr/qt5.5
export  LD_LIBRARY_PATH=/lib:/usr/lib:$QT_ROOT/lib
export  QT_QPA_PLATFORM_PLUGIN_PATH=$QT_ROOT/plugins
export  QT_QPA_PLATFORM=linuxfb:fb=/dev/fb1
export  QT_QPA_FONTDIR=$QT_ROOT/lib/fonts
export  QML2_IMPORT_PATH=$QT_ROOT/qml
第三种方式:buildroot中配置勾选QT选项,使其生成QT相关的库和插件,这种方式因电脑配置低,buildroot编译的时候到一半虚拟机就卡死了,未能成功测试
   但使用了一个别人用buildroot编好的根文件系统,执行QT程序的时候报告:
QStandardPaths:XDG_RUNTIME_DIR not set,defaulting to '/tmp/runtime-root'
segmentation  fault
然后使用了一个简单的QWidget程序跟踪了下代码:发现段错误发生在:
QApplication  a(argc,argv)处,即任何对象都还没有被创建之前。所以怀疑是库本身的问题。或者是环境变量的问题,但按照道理所有的QT库和插件都
被buildroot编译在默认搜索路径下,可以不用配置环境变量,可直接执行的(最多指定显示插件,但发现即使指定显示插件之后也没能成功),问题待定。
所以还是采用了第二种方式进行QT移植。
至此移植完成

/******************************************移植过程中遇到的一些问题**************************************/
①/*************************************************************************************/
Cannot find libdbus-1 in your system to resolve symbol 'dbus_get_local_machine_id'.
Aborted ******************************************************************************错误原因:没有dbus库,移植dbus库,qt源码编译加上-dbus选项
②/************************************************************************************/
process 85: D-Bus library appears to be incorrectly set up; failed to read machine uuid: Failed to
open “/opt/EmbedRigol/install-dev/dbus-1.2.30/var/lib/dbus/machine-id”: No such file or directory
See the manual page for dbus-uuidgen to correct this issue.
D-bus not built with -rdynamic so unable to print abacktrace
Aborted******************************************************************************错误原因:没有在qmake.conf中指定dbus
③/**********************************************************************************/
QIconvCodec::convertToUnicode: using Latin-1 for conversion,iconv_open failed
QIconvCodec::convertFromUnicode: using Latin-1 for conversion,iconv_open failed*************解决配置时加-no-iconv
④/********************************************************************************/
process 2622: D-Bus library appears to be incorrectly set up; failed to read machine uuid: Failed to open "/usr/var/lib/dbus/machine-id": No such file or directory
See the manual page for dbus-uuidgen to correct this issue.
D-Bus not built with -rdynamic so unable to print a backtrace
Aborted*************************************创建/usr/var/lib/dbus/machine-id,然后dbus-uuidgen > /usr/var/lib/dbus/machine-id
遇到更多问题可参见:https://blog.csdn.net/xishuang_gongzi/article/details/49583821及网上其它博客

猜你喜欢

转载自blog.csdn.net/ass_dsb/article/details/80250729