Building QT5 for IMX6(all)

address:https://community.freescale.com/docs/DOC-94066

Prerequisites:
The build is verified on prebuilt rootfs(based on LTIB) which can be downloaded from freescale.com

EGL uses framebuffer backend
libEGL.so -> libEGL-fb.so
libGAL.so -> libGAL-fb.so

QT4.8

1. Download the git respository for qt4.8:

$ git clone http://git.gitorious.org/qt/qt.git qt
$ cd qt

Let us consider this as <QTDir>

2. Create /tftpboot and point your target fileystem. As like

$ mkdir -p /tftpboot

$ cd /tftpboot

$ ln -s $(ROOTFFS) rootfs

TBD:Need to work on this to use sysroot option

3. Create a build directory to install for the qt4 packages. This directory can be  in any location. For example,

$ mkdir /opt/qt4
$ sudo chown -R <username> /opt/qt4

Let us consider the the <installdir> as /opt/qt4

4. Extract the attached mkspecs(linux-imx6-g++.tar.gz) to  <QTDir>/mkspecs/qws/

5. Apply the attached cd 0001-add-i.MX6-EGL-support.patch attached to enable egl support for i.MX6

$ cd <QTDir>
$ patch -p1<0001-add-i.MX6-EGL-support.patch

6. Export CROSS-COMPILE location path to PATH

$ export PATH=$PATH:/opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/

7. Enter to the <QTDir>. Do configure. You can select the options as you like. Here is an example

$ cd <QTDir>

$ ./configure -qpa -arch arm -xplatform qws/linux-imx6-g++ -no-largefile -no-accessibility \
-opensource -verbose -system-libpng -system-libjpeg -system-freetype -fast -opengl es2 -egl -confirm-license \
-qt-zlib  -qt-libpng  -no-webkit -no-multimedia \
-make examples -make demos \
-release -make libs -exceptions -no-qt3support -prefix <installdir>

8. When the configure summary is shown make sure the Qt has OpenGL ES 2.0 support. Do build

$ make
$ make install

9. Now need to build eglfs plugin

$ cd <QTDir>/src/plugins/platforms/eglfs
$ make
$ make install

    Now the eglfs will be installed to the QT Install directory.

10. By now all required QT files are in <install directory>

11. Copy the install directory to target filesystem

$ cp -rf /opt/qt4 /tftpboot/rootfs/opt/.

12. Running Qt apps on target
    - Boot the target either with NFS or SD Image
    - Ensure that folder <installdir> is copied on target file system at “/usr/local”.
    - Launch application using

$ cd /opt/qt4/examples/opengl/hellogl_es2
$ ./hellogl_es2 -platform eglfs

QT5

These steps are performed on the host

1. Download the git respository for qt5:

$ git clone git://gitorious.org/qt/qt5.git qt5

$ cd qt5

    Let us consider this as <QTDir>

2. Create a build directory to install for the qt5 packages. This directory can be  in any loctation. For example,

$ sudo mkdir /opt/qt5

$ sudo chown -R <username> /opt/qt5

Let us consider the the installdir as /opt/qt5

3. Enter the Qt5 directory and run the init-repository script to download all the source code for
   Qt5. To download all the source code will take about an hour.

$ ./init-repository

Update:  In the latest Qt5 release the webkit library is included by default and there are some issues trying to compile it.

use the next line to avoid problems if not desired to use webkit.

$ ./init-repository --no-webkit

4. From the following path

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

5. At the top of the qmake.conf, there is a configure line. Copy and paste the configure line into a text file located
   in your build build directory. Edit the configure line to find your toolchain and filesystem. Also make sure to
   include the options -no-pch, -no-opengl, -opengl es2, Here is an example of
   a configure line.

Update: In the latest Qt5 stable, the option to compile the examples/demos is -compile-examples, instead of -make examples -make demos

If you are running into problems with webkit,  use the option -no-icu, this will disable the webkit.

$ cd <QTDir>
$ cd qtbase
$ ./configure -v -opensource -confirm-license -no-pch -no-xcb -no-opengl -opengl es2  \
        -make libs -device imx6 \
       -compile-examples \
      -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- \
       -sysroot <rootfs> -no-gcc-sysroot \
      -prefix <installdir>

7. Make the textfile that has the configure line and executable and run it. When the configure summary is shown make sure the Qt5 has openGL ES 2.0 support. Do build

$ make
$ sudo make install

   When Qt5 has finished building, Qt5 will be installed in two places:

           1. <location of rootfs>/<installdir>
           2. <HOST Machine>/<install dir>

This is good because now all the libraries and binaries for Qt5 are installed on the host and the target filesystem. Therefore, the target already has all the libraries and  binaries needed to run Qt5.

8. Also need to build qtjsbackend and qtdeclarative.

$ cd <location to Qt5 git>
$ cd qtjsbackend
$ ../qtbase/bin/qmake -r
$ make && sudo make install

$ cd <location to Qt5 git>
$ cd qtdeclarative
$ ../qtbase/bin/qmake -r
$ make && sudo sudo make install

9. Running Qt apps on target
    - Boot the target either with NFS or SD Image
    - Ensure that folder <installdir> is copied on target file system at “/usr/local”.
    - Launch application using

$ cd /opt/qt5/examples/opengl/hellowindow
$ ./hellowindow -platform eglfs

FAQ:
On the target file system, the location of target libaries and includes may present in arm-linux-gnueabi directory. Make sure to create soflinks to QT can find. For example

$ cd $(ROOTFS)/usr/lib
$ ln -s arm-linux-gnueabi/libffi.so.6 libffi.so.6

While building QT5, you may see a build error that libQt5V8.so.5 is not found. This might be some problem to be addressed in QT. Workaround is to
copy all the binaries to correct path as like this

$ cp  <ROOTFS>/<installdir>/lib/* <HOST Machine>/<installdir>/.

What is coming up next:
1. QT on X is already available on Yocto filesystem. Steps to enable GPU Acceleration TDB.
2. QT with Wayland support.

posted @ 2015-06-09 09:52  不二侬  阅读(1616)  评论(0编辑  收藏  举报