Qt5.5.1移植到freescale imx6


一、環境

HOST:ubuntu12.04-LTS

Embedded:freescale imx6 linux-3.0.35

CROSS_COMPILE:freescale提供的gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/arm-fsl-linux-gnueabi-

 

二、下載源碼

http://mirrors.ustc.edu.cn/qtproject/archive/qt/5.5/5.5.1/single/qt-everywhere-opensource-src-5.5.1.tar.gz

 

三、解壓

unzip qt-everywhere-opensource-src-5.5.1.tar.gz

cd qt-everywhere-opensource-src-5.5.1

 

四、指定arm架構、交叉編譯器、包含的文件系統頭文件、部分編譯參數

vi qtbase/mkspecs/devices/linux-imx6-g++/qmake.conf

以下為全部內容,其他平台qtbase/mkspecs/devices/下要是沒有單獨提供,可以使用qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf,需根據自己平台做相應修改。

 

[cpp]  view plain  copy
 
 print?
  1. #  
  2. # qmake configuration for the Freescale iMX6 boards (single, dual and quad)  
  3. #  
  4. #export CROSS_COMPILE=/opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/arm-fsl-linux-gnueabi-  
  5. MAKEFILE_GENERATOR      = UNIX   #宏定義,代碼中有判斷  
  6. CONFIG                 += incremental  
  7. QMAKE_INCREMENTAL_STYLE = sublib  
  8.   
  9. QT_QPA_DEFAULT_PLATFORM = linuxfb #eglfs    #顯示使用linuxfb或eglfs  
  10. IMX6_CFLAGS             = -march=armv7-a -mfpu=neon -DLINUX=1 -DEGL_API_FB=1    #處理器架構  
  11. IMX6_CFLAGS_RELEASE     = -O2 $$IMX6_CFLAGS  
  12. QMAKE_CFLAGS_RELEASE   += $$IMX6_CFLAGS_RELEASE  
  13. QMAKE_CXXFLAGS_RELEASE += $$IMX6_CFLAGS_RELEASE  
  14. QMAKE_CFLAGS           += $$IMX6_CFLAGS  
  15. QMAKE_CXXFLAGS         += $$IMX6_CFLAGS  
  16.   
  17. include(../common/linux_device_pre.conf)  
  18. include(../../common/linux.conf)  
  19. include(../../common/gcc-base-unix.conf)  
  20. include(../../common/g++-unix.conf)  
  21.   
  22. # modifications to g++.conf  
  23. QMAKE_CC                = /opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/arm-fsl-linux-gnueabi-gcc  
  24. QMAKE_CXX               = /opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/arm-fsl-linux-gnueabi-g++  
  25. QMAKE_LINK              = /opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/arm-fsl-linux-gnueabi-g++  
  26. QMAKE_LINK_SHLIB        = /opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/arm-fsl-linux-gnueabi-g++  
  27.   
  28. # modifications to linux.conf  
  29. QMAKE_AR                = /opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/arm-fsl-linux-gnueabi-ar cqs  
  30. QMAKE_OBJCOPY           = /opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/arm-fsl-linux-gnueabi-objcopy  
  31. QMAKE_STRIP             = /opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/arm-fsl-linux-gnueabi-strip  
  32.   
  33. QMAKE_INCDIR            += /imx_disk/gq/qt/rootfs/usr/include  
  34. QMAKE_LIBDIR            += /imx_disk/gq/qt/rootfs/usr/lib  
  35.   
  36. QMAKE_INCDIR            += /imx_disk/gq/qt/rootfs/usr/include/dbus-1.0  
  37. QMAKE_INCDIR            += /imx_disk/gq/qt/rootfs/usr/lib/dbus-1.0/include  
  38. QMAKE_LIBDIR            += /imx_disk/gq/qt/rootfs/usr/lib  
  39.   
  40. QMAKE_INCDIR_OPENGL_ES2 = /imx_disk/gq/qt/rootfs/usr/include  
  41. QMAKE_LIBDIR_OPENGL_ES2 = /imx_disk/gq/qt/rootfs/usr/lib  
  42.   
  43. QMAKE_INCDIR_EGL = /imx_disk/gq/qt/rootfs/usr/include  
  44. QMAKE_LIBDIR_EGL = /imx_disk/gq/qt/rootfs/usr/lib  
  45.   
  46. QMAKE_LIBS_OPENGL_ES1       += -lGLESv1_CM -lEGL -lGAL  
  47. QMAKE_LIBS_OPENGL_ES1CL     += -lGLES_CL -lEGL -lGAL  
  48. QMAKE_LIBS_EGL         += -lEGL  
  49. QMAKE_LIBS_OPENGL_ES2  += -lGLESv2 -lEGL -lGAL  
  50. QMAKE_LIBS_OPENVG      += -lOpenVG -lEGL -lGAL  
  51. QMAKE_LIBS             += -ljpeg -ldbus-1 -lrt -lpthread    #編譯選項  
  52. #DISTRO_OPTS += hard-float          #浮點運算使用軟件不使用硬件  
  53.   
  54.   
  55. # Preferred eglfs backend  
  56. EGLFS_DEVICE_INTEGRATION = eglfs_viv  
  57.   
  58. include(../common/linux_arm_device_post.conf)  
  59.   
  60. load(qt_config)  


五、根據自己實際需求配置QT

 

 

[cpp]  view plain  copy
 
 print?
  1. #!/bin/sh  
  2. ./configure \  
  3.         -v -opensource -confirm-license -no-pch -no-xcb -no-openssl -no-opengl -opengl es2 \  
  4.         -dbus \  
  5.         -qt-zlib \  
  6.         -no-sse2 \  
  7.         -no-iconv \  
  8.         -tslib \  
  9.         -release \  
  10.         -make libs -device imx6 \  
  11.         -device-option CROSS_COMPILE=/opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/arm-fsl-linux-gnueabi- \  
  12.         -sysroot /imx_disk/gq/qt/ -no-gcc-sysroot \  
  13.         -prefix /qt5.5.1 \  
  14.         -make examples -nomake tools -nomake tests  


配置結果如下:

 

 

[cpp]  view plain  copy
 
 print?
  1. Build options:  
  2.   Configuration .......... accessibility alsa audio-backend c++11 clock-gettime clock-monotonic compile_examples concurrent cross_compile dbus eglfs_viv enable_new_dtags evdev eventfd freetype full-config getaddrinfo getifaddrs harfbuzz inotify ipv6ifname large-config largefile linuxfb medium-config minimal-config mremap neon nis no-pkg-config opengl opengles2 openvg pcre png posix_fallocate qpa qpa reduce_exports release rpath shared small-config system-jpeg tslib zlib  
  3.   Build parts ............  libs examples  
  4.   Mode ................... release  
  5.   Using sanitizer(s)...... none  
  6.   Using C++11 ............ yes  
  7.   Using gold linker....... no  
  8.   Using new DTAGS ........ yes  
  9.   Using PCH .............. no  
  10.   Target compiler supports:  
  11.     Neon ................. yes  
  12.   
  13. Qt modules and options:  
  14.   Qt D-Bus ............... yes (loading dbus-1 at runtime)  
  15.   Qt Concurrent .......... yes  
  16.   Qt GUI ................. yes  
  17.   Qt Widgets ............. yes  
  18.   Large File ............. yes  
  19.   QML debugging .......... yes  
  20.   Use system proxies ..... no  
  21.   
  22. Support enabled for:  
  23.   Accessibility .......... yes  
  24.   ALSA ................... yes  
  25.   CUPS ................... no  
  26.   Evdev .................. yes  
  27.   FontConfig ............. no  
  28.   FreeType ............... yes (bundled copy)  
  29.   Glib ................... no  
  30.   GStreamer .............. no  
  31.   GTK theme .............. no  
  32.   HarfBuzz ............... yes (bundled copy)  
  33.   Iconv .................. no  
  34.   ICU .................... no  
  35.   Image formats:  
  36.     GIF .................. yes (plugin, using bundled copy)  
  37.     JPEG ................. yes (plugin, using system library)  
  38.     PNG .................. yes (in QtGui, using bundled copy)  
  39.   journald ............... no  
  40.   libinput................ no  
  41.   mtdev .................. no  
  42.   Networking:  
  43.     getaddrinfo .......... yes  
  44.     getifaddrs ........... yes  
  45.     IPv6 ifname .......... yes  
  46.     libproxy.............. no  
  47.     OpenSSL .............. no  
  48.   NIS .................... yes  
  49.   OpenGL / OpenVG:  
  50.     EGL .................. no  
  51.     OpenGL ............... yes (OpenGL ES 2.0+)  
  52.     OpenVG ............... yes-auto  
  53.   PCRE ................... yes (bundled copy)  
  54.   pkg-config ............. no  
  55.   PulseAudio ............. no  
  56.   QPA backends:  
  57.     DirectFB ............. no  
  58.     EGLFS ................ no  
  59.       EGLFS i.MX6....... . yes  
  60.       EGLFS KMS .......... no  
  61.       EGLFS Mali ......... no  
  62.       EGLFS Raspberry Pi . no  
  63.       EGLFS X11 .......... no  
  64.     LinuxFB .............. yes  
  65.     XCB .................. no  
  66.   Session management ..... yes  
  67.   SQL drivers:  
  68.     DB2 .................. no  
  69.     InterBase ............ no  
  70.     MySQL ................ no  
  71.     OCI .................. no  
  72.     ODBC ................. no  
  73.     PostgreSQL ........... no  
  74.     SQLite 2 ............. no  
  75.     SQLite ............... yes (plugin, using bundled copy)  
  76.     TDS .................. no  
  77.   tslib .................. yes  
  78.   udev ................... no  
  79.   xkbcommon-x11........... no  
  80.   xkbcommon-evdev......... no  
  81.   zlib ................... yes (bundled copy)  


六、編譯安裝

 

1、make

2、make install

 

七、copy到開發板設置環境變量

1、將qt5.5.1打包拷貝到文件系統/usr/local/下,其中包含了qt5的examples,可以刪除。

2、添加QT系統環境變量

vi /etc/profile添加
#for QT
export QT_ROOT=/usr/local/qt5.5.1
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib:/usr/lib:$QT_ROOT/lib
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 QT_QPA_GENERIC_PLUGINS=evdevtouch:/dev/input/event0
export PATH=/bin:/sbin:/usr/bin/:/usr/sbin

export QML2_IMPORT_PATH=$QT_ROOT/qml

#export QT_QPA_GENERIC_PLUGINS=tslib:$TSLIB_TSDEVICE//如果觸摸使用TSlib支持則修改為該句。

#export QT_QPA_EGLFS_FB=/dev/fb1

注:QT觸摸屏支持可以不使用tslib。

3、tslib移植及支持請看http://blog.csdn.net/xishuang_gongzi/article/details/49422879

 

八、運行例子

注:圖懶得截了,從別人處拷貝的。

examples/touch/pinchzoom/pinchzoom



examples/svg/embedded/fluidlauncher/fluidlauncher



九、編譯及運行問題記錄

1、編譯錯誤:opengles2.cpp:37:25: fatal error: GLES2/gl2.h: No such file or directory

vi qtbase/mkspecs/devices/linux-imx6-g++/qmake.conf

解決:

QMAKE_INCDIR_OPENGL_ES2 = /imx_disk/gq/qt/rootfs/usr/include
QMAKE_LIBDIR_OPENGL_ES2 = /imx_disk/gq/qt/rootfs/usr/lib


2、編譯錯誤:In function `png_reset_crc': png.c: undefined reference to `z_crc32'等,qtbase/src/3rdparty/libpng編譯時出現大量z_開頭的zlib庫函數找不到定義。

解決:

./configure 后添加編譯-qt-zlib
qt為了防止自己的zlib庫與系統的zlib庫沖突。Since Qt Core must export these symbols, define Z_PREFIX to avoid clashes system zlib */


3、編譯錯誤:

運行時出現錯誤提示

QIconvCodec::convertToUnicode: using Latin-1 for conversion,iconv_open failed
QIconvCodec::convertFromUnicode: using Latin-1 for conversion,iconv_open failed
解決:

./configure 后添加編譯 -no-iconv


4、編譯錯誤qtwebkit/lib/libQt5WebKit.so: undefined reference to `jpeg_input_complete'

解決:

./configure 后添加編譯-qt-libjpeg

 

5、編譯錯誤:arm-fsl-linux-gnueabi/bin/ld: warning: libjpeg.so.62, needed by /.....qtwebkit/lib/libQt5WebKit.so, not found (try using -rpath or -rpath-link)

解決:
vi qtbase/mkspecs/devices/linux-imx6-g++/qmake.conf添加
QMAKE_LIBS             += -ljpeg
http://blog.sina.com.cn/s/blog_616fb0880100xrjj.html

 

6、編譯錯誤:

qibusplatforminputcontext.cpp: In member function 'virtual void QIBusPlatformInputContext::reset()':
qibusplatforminputcontext.cpp:117:17: error: 'class QIBusInputContextProxy' has no member named 'Reset'
qibusplatforminputcontext.cpp: In member function 'virtual void QIBusPlatformInputContext::commit()':
qibusplatforminputcontext.cpp:140:17: error: 'class QIBusInputContextProxy' has no member named 'Reset'

解決:

qt編譯./configuer 后加上-dbus 

 

7、配置錯誤:

The Qt D-Bus module cannot be enabled because libdbus-1 version 1.2 was not found.
解決:

參考:找到-prefix目錄下的lib文件下的pkgconfig文件夾,打開dbus-1.pc
vi qtbase/mkspecs/devices/linux-imx6-g++/qmake.conf

QMAKE_INCDIR            += /imx_disk/gq/qt/rootfs/usr/include/dbus-1.0
QMAKE_INCDIR            += /imx_disk/gq/qt/rootfs/usr/lib/dbus-1.0/include
QMAKE_LIBDIR            += /imx_disk/gq/qt/rootfs/usr/lib

若rootfs中沒有dbus庫,則需要移植dbus1.2版本copy到文件系統,添加參數如下

QMAKE_INCDIR            += /imx_disk/gq/qt/dbus/dbusinstall_1.2.30/include/dbus-1.0
QMAKE_INCDIR            += /imx_disk/gq/qt/dbus/dbusinstall_1.2.30/lib/dbus-1.0/include
QMAKE_LIBDIR            += /imx_disk/gq/qt/dbus/dbusinstall_1.2.30/lib
其中dbusinstall_1.2.30是交叉編譯dbus1.2后的安裝目錄。
編譯dbus前需要先交叉編譯dbus的依賴庫expat-2.1.0

 
8、運行錯誤./examples/touch/pinchzoom/pinchzoom 
Cannot find libdbus-1 in your system to resolve symbol 'dbus_get_local_machine_id'.
Aborted
qt編譯./configuer 后加上-dbus
 

9、編譯錯誤:

/imx_disk/gq/qt/dbus/dbusinstall_1.2.30/lib/libdbus-1.a(dbus-sysdeps-pthread.o): In function `_dbus_pthread_condvar_wait_timeout':
/imx_disk/gq/qt/dbus/dbus-1.2.30/dbus/dbus-sysdeps-pthread.c:273: undefined reference to `clock_gettime'
/imx_disk/gq/qt/dbus/dbusinstall_1.2.30/lib/libdbus-1.a(dbus-sysdeps-pthread.o): In function `_dbus_pthread_condvar_new':
/imx_disk/gq/qt/dbus/dbus-1.2.30/dbus/dbus-sysdeps-pthread.c:206: undefined reference to `pthread_condattr_setclock'
/imx_disk/gq/qt/dbus/dbusinstall_1.2.30/lib/libdbus-1.a(dbus-sysdeps-pthread.o): In function `check_monotonic_clock':
/imx_disk/gq/qt/dbus/dbus-1.2.30/dbus/dbus-sysdeps-pthread.c:353: undefined reference to `clock_getres'
/imx_disk/gq/qt/dbus/dbusinstall_1.2.30/lib/libdbus-1.a(dbus-sysdeps-unix.o): In function `_dbus_get_current_time':
/imx_disk/gq/qt/dbus/dbus-1.2.30/dbus/dbus-sysdeps-unix.c:2071: undefined reference to `clock_gettime'

解決:
vi qtbase/mkspecs/devices/linux-imx6-g++/qmake.conf
QMAKE_LIBS             += -lrt

 

10、編譯錯誤:

qsgvivantevideonode.cpp: In static member function 'static const QMap<QVideoFrame::PixelFormat, unsigned int>& QSGVivanteVideoNode::getVid   eoFormat2GLFormatMap()':
qsgvivantevideonode.cpp:64:77: error: 'GL_VIV_I420' was not declared in this scope

解決:方式兩種,選一種,我們選第二種
①、
vi ./qtmultimedia/src/plugins/videonode/imx6/qsgvivantevideonode.cpp
const QMap<QVideoFrame::PixelFormat, GLenum>& QSGVivanteVideoNode::getVideoFormat2GLFormatMap()
{
    if (static_VideoFormat2GLFormatMap.isEmpty()) {
//        static_VideoFormat2GLFormatMap.insert(QVideoFrame::Format_YUV420P,  GL_VIV_I420);
//this video format needs to be commented because it will have support with kernel 3.10 but not with actual one
        static_VideoFormat2GLFormatMap.insert(QVideoFrame::Format_YV12,     GL_VIV_YV12);
        static_VideoFormat2GLFormatMap.insert(QVideoFrame::Format_NV12,     GL_VIV_NV12);
        static_VideoFormat2GLFormatMap.insert(QVideoFrame::Format_NV21,     GL_VIV_NV21);
        static_VideoFormat2GLFormatMap.insert(QVideoFrame::Format_UYVY,     GL_VIV_UYVY);
        static_VideoFormat2GLFormatMap.insert(QVideoFrame::Format_YUYV,     GL_VIV_YUY2);
        static_VideoFormat2GLFormatMap.insert(QVideoFrame::Format_RGB32,    GL_BGRA_EXT);
        static_VideoFormat2GLFormatMap.insert(QVideoFrame::Format_ARGB32,   GL_BGRA_EXT);
        static_VideoFormat2GLFormatMap.insert(QVideoFrame::Format_BGR32,    GL_RGBA);
        static_VideoFormat2GLFormatMap.insert(QVideoFrame::Format_BGRA32,   GL_RGBA);
        static_VideoFormat2GLFormatMap.insert(QVideoFrame::Format_RGB565,   GL_RGB565);
    }


    return static_VideoFormat2GLFormatMap;
}



vi rootfs/usr/include/GLES2/gl2ext.h
/* GL_VIV_direct_texture */
#ifndef GL_VIV_direct_texture
#define GL_VIV_YV12                     0x8FC0
#define GL_VIV_NV12                     0x8FC1
#define GL_VIV_YUY2                     0x8FC2
#define GL_VIV_UYVY                     0x8FC3
#define GL_VIV_NV21                     0x8FC4
#define GL_VIV_I420                     0x8FC5 //新增
#endif
值來自於這個patch    https://lists.yoctoproject.org/pipermail/meta-freescale/2014-June/008709.html


11、編譯錯誤:

ssl/qsslcontext_openssl.cpp:444:52: error: 'SSL_SESSION' has no member named 'tlsext_tick_lifetime_hint'
解決:

configure編譯時添加-no-openssl,即不編譯openssl


12、運行錯誤:

./examples/quick/demos/samegame/samegame 
qrc:///demos/samegame/samegame.qml:41:1: module "QtQuick" is not installed
qrc:///demos/samegame/samegame.qml:42:1: module "QtQuick.Particles" is not installed
qrc:///demos/samegame/samegame.qml:41:1: module "QtQuick" is not installed
qrc:///demos/samegame/samegame.qml:42:1: module "QtQuick.Particles" is not installed

解決:

在環境里添加:export QML2_IMPORT_PATH=$QT_ROOT/qml,就能解決qrc:///main.qml:1 module "QtQuick" is not installed這樣類似的問題,

$QT_ROOT/qml是你編譯安裝后會有個文件夾的。

13、運行錯誤:./examples/quick/demos/samegame/samegame 

This plugin does not support createPlatformOpenGLContext!
Failed to create OpenGL context for format QSurfaceFormat(version 2.0, options QFlags(), depthBufferSize 24, redBufferSize -1, greenBufferSize -1, blueBufferSize -1, alphaBufferSize -1, stencilBufferSize 8, samples -1, swapBehavior 2, swapInterval 1, profile  0) 
Aborted
回答:

The problem is likely that you are using qt quick 2, which requires OpenGL. OpenGL does not support the frame buffer used for the small display.


14、編譯錯誤:

../WTF/wtf/unicode/wchar/UnicodeWchar.h: In function 'bool WTF::Unicode::isAlphanumeric(UChar)':

../WTF/wtf/unicode/wchar/UnicodeWchar.h:136:58: error: 'iswalnum' was not declared in this scope
../WTF/wtf/unicode/wchar/UnicodeWchar.h: In function 'bool WTF::Unicode::isDigit(UChar)':
../WTF/wtf/unicode/wchar/UnicodeWchar.h:137:51: error: 'iswdigit' was not declared in this scope
../WTF/wtf/unicode/wchar/UnicodeWchar.h: In function 'bool WTF::Unicode::isLetter(UChar)':

解決:
vi ./qtwebkit/Source/WTF/wtf/unicode/wchar/UnicodeWchar.h
#ifndef Android
/*add by gq start*/
#include <wctype.h>
typedef unsigned short int UChar;
/*add by gq end*/
//# include <wchar.h>
// typedef wchar_t UChar;
#else
 typedef unsigned short int UChar;
#endif


15、編譯錯誤:cc1plus: error: unrecognized command line option '-fuse-ld=gold'
解決:

這是Qt的一個bug:https://bugs.webkit.org/show_bug.cgi?id=89312
在裝有gold linker的系統里,編譯腳本會加入-fuse-ld=gold選項,但這個選項gcc是不支持的。解決辦法是移除該選項,
vi qtbase/configure
CFG_USE_GOLD_LINKER=no


16、編譯錯誤3、arm-fsl-linux-gnueabi/bin/ld: error: arch.o uses VFP register arguments, arch does not

解決:

vi./qtbase/mkspecs/devices/linux-imx6-g++/qmake.conf
#DISTRO_OPTS += hard-float
屏蔽掉該句后
g++編譯器就被設置成-mfloat-abi=softfp,不使用hard,即浮點運算使用軟件不使用硬件。


17、運行錯誤:
root@freescale /opt$ ./examples/svg/embedded/fluidlauncher/fluidlauncher 
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

解決:
dbus-uuidgen > /usr/var/lib/dbus/machine-id


十、主要參考
https://community.freescale.com/docs/DOC-94066
http://www.myir-tech.com/bbs/thread-7174-1-1.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM