Tuesday 7 January 2014

Qt-5.1.1

Hi all,
cross compiling is rocket science for some. let me list down all the steps which i followed to cross compile Qt 5.1.1 for freescale imx6 board.

first download qt-everywhere-opensource-src-5.1.1.tar.gz.
then untar it on your home folder.
1. sakshi@sakshi:~$ tar -xvf qt-everywhere-opensource-src-5.1.1.tar.gz

then go to the source folder:
2. cd qt-everywhere-opensource-src-5.1.1/qtbase

3. write a script to configure qt for your target :
sakshi@sakshi:~/qt-everywhere-opensource-src-5.1.1/qtbase$ vi config.imx6

#!/bin/sh
./configure --prefix=/tools/rootfs/usr/local/qt-5.1.1 -examplesdir /tools/rootfs/usr/local/qt-5.1.1/examples -verbose -opensource -confirm-license -make libs -make examples -device imx6 \
-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- \
-no-pch -no-opengl -no-icu -no-xcb -no-c++11 \
-opengl es2 \
-eglfs \
-compile-examples \
-glib -gstreamer -pkg-config -no-directfb\

4. go to mkspeck folder to do the required configuration for qmake:
sakshi@sakshi:~/qt-everywhere-opensource-src-5.1.1/qtbase$cd ../mkspecs/devices/
sakshi@sakshi:~/qt-everywhere-opensource-src-5.1.1/qtbase/mkspecs/devices$ mkdir linux-imx6-g++
sakshi@sakshi:~/qt-everywhere-opensource-src-5.1.1/qtbase/mkspecs/devices$ cd  linux-imx6-g++
sakshi@sakshi:~/qt-everywhere-opensource-src-5.1.1/qtbase/mkspecs/devices/linux-imx6-g++$vi qmake.conf
include(../common/linux_device_pre.conf)
ROOTFS=/tools/rootfs
EGLFS_PLATFORM_HOOKS_SOURCES = $$PWD/qeglfshooks_imx6.cpp

QMAKE_INCDIR           += $$ROOTFS/usr/include \
                          $$ROOTFS/usr/include/glib-2.0 \
                          $$ROOTFS/usr/include/glib-2.0/gio \
                          $$ROOTFS/usr/include/glib-2.0/glib \
                          $$ROOTFS/usr/include/glib-2.0/gobject \
                          $$ROOTFS/usr/include/glib-2.0/include \
                          $$ROOTFS/usr/include/gstreamer-0.10 \
                          $$ROOTFS/usr/include/libxml2
QMAKE_LIBDIR           += $$ROOTFS/usr/lib
QMAKE_LIBS             += -L/tools/rootfs/usr/lib -lgthread-2.0 -lgio-2.0 -lglib-2.0 -lgmodule-2.0 -lgobject-2.0 -lgstbase-0.10 -lgstcontroller-0.10 -lgstreamer-0.10
QMAKE_INCDIR_OPENGL_ES2+= $$ROOTFS/usr/include/GLES2
QMAKE_LIBDIR_OPENGL_ES2+= $$ROOTFS/usr/lib
QMAKE_LIBS_EGL         += -lEGL
QMAKE_LIBS_OPENGL_ES2  += -lGLESv2 -lEGL -lGAL
QMAKE_LIBS_OPENVG      += -lOpenVG -lEGL -lGAL

QMAKE_LFLAGS           += -Wl,-rpath-link,$$ROOTFS/usr/lib

IMX6_CFLAGS             = -march=armv7-a -mfpu=neon -DLINUX=1 -DEGL_API_FB=1
IMX6_CFLAGS_RELEASE     = -O2 $$IMX6_CFLAGS
QMAKE_CFLAGS_RELEASE   += $$IMX6_CFLAGS_RELEASE
QMAKE_CXXFLAGS_RELEASE += $$IMX6_CFLAGS_RELEASE
QMAKE_CFLAGS_DEBUG     += $$IMX6_CFLAGS
QMAKE_CXXFLAGS_DEBUG   += $$IMX6_CFLAGS

include(../common/linux_device_post.conf)

load(qt_config)

5. go to qtbase and export the required path and configure qt:
sakshi@sakshi:~/qt-everywhere-opensource-src-5.1.1/qtbase/mkspecs/devices/linux-imx6-g++$cd ../../../
sakshi@sakshi:~/qt-everywhere-opensource-src-5.1.1/qtbase$export PKG_CONFIG_DIR=
sakshi@sakshi:~/qt-everywhere-opensource-src-5.1.1/qtbase$export PKG_CONFIG_LIBDIR=/tools/rootfs/usr/lib/pkgconfig/
sakshi@sakshi:~/qt-everywhere-opensource-src-5.1.1/qtbase$export PKG_CONFIG_SYSROOT_DIR=/tools/rootfs
sakshi@sakshi:~/qt-everywhere-opensource-src-5.1.1/qtbase$ ./config.imx6
   
6. after this do make and make install
sakshi@sakshi:~/qt-everywhere-opensource-src-5.1.1/qtbase$ make
sakshi@sakshi:~/qt-everywhere-opensource-src-5.1.1/qtbase$ make install

which will install qt in /tools/rootfs/usr/local/qt-5.1.1.
You can run your qt application on target.


Happy to Help :):)



15 comments:

  1. Thanks a lot sakshi..:)

    ReplyDelete
  2. And after the installation on the host PC, what need I do to the target board before I run a application on it?
    Need I copy the qt-5.1.1 to the board?
    Thank you.

    ReplyDelete
  3. Yes yini..copy the executables which is qt-5.1.1 on your target file system.
    if your board has gcc support then u need not cross compile it. just copy qt source to the target and compile it on board. but building on host is more convenient.

    When you build your own application using qt export qmake path before compiling your application(qt-5.1.1/bin).

    ReplyDelete
    Replies
    1. By the gcc support, do you mean fsl toolchain?
      And if I want to build Qt development environment on the board, actually I maybe do the same as on the host, and the difference is I need not to copy the files to the board right?

      Delete
    2. when u do apt get install gcc on board you will get all gcc related things on your board.

      on your host you write a program test.c and you compile it using
      :gcc test.c -o test
      rite?
      if you are cross compiling the same code for the board you use tool chain on host:
      arm-fsl-linux-gnueabi-gcc test.c -o test
      isnt it???
      so.. if you want to compile it on board you do apt get-install gcc which will give you gcc binaries on your target. then copy the test.c on target and do
      gcc test.c -o test. on target....
      It is one and same. if you are building a program on host for target then you need cross compiler because if u use gcc on host it will be incompatible for target. each target has got its own binaries.. :)

      Delete
    3. Thank you for the answer.
      And just to confirm that, you can run programs with dialogs and multimedia player smoothly on your target right?

      Delete
  4. error=>
    OpenGL ES 2.x auto-detection... ()
    /opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro
    -toolchain/bin/arm-fsl-linux-gnueabi-g++
    -c -pipe -mfloat-abi=softfp -O2 -O2 -march=armv7-a -mfpu=neon -DLINUX=1
    -DEGL_API_FB=1 -Wall -W -fPIE -I../../../mkspecs/devices/linux-imx6-g++
    -I. -I/home/sachin/ltib/rootfs/usr/include/GLES2
    -I/home/sachin/ltib/rootfs/usr/include
    -I/home/sachin/ltib/rootfs/usr/include/glib-2.0
    -I/home/sachin/ltib/rootfs/usr/include/glib-2.0/gio
    -I/home/sachin/ltib/rootfs/usr/include/glib-2.0/glib
    -I/home/sachin/ltib/rootfs/usr/include/glib-2.0/gobject
    -I/home/sachin/ltib/rootfs/usr/include/glib-2.0/include
    -I/home/sachin/ltib/rootfs/usr/include/gstreamer-0.10
    -I/home/sachin/ltib/rootfs/usr/include/libxml2 -o opengles2.o opengles2.cpp
    opengles2.cpp:45:25: fatal error: GLES2/gl2.h: No such file or directory
    compilation terminated.
    make: *** [opengles2.o] Error 1
    OpenGL ES 2.x disabled.
    The OpenGL ES 2.0 functionality test failed!
    You might need to modify the include and library search paths by editing
    QMAKE_INCDIR_OPENGL_ES2, QMAKE_LIBDIR_OPENGL_ES2 and QMAKE_LIBS_OPENGL_ES2
    in
    /home/sachin/qt-everywhere-opensource-src-5.1.1/qtbase/mkspecs/devices/linux-imx
    6-g++.

    ReplyDelete
    Replies
    1. Sorry to see this comment late.. is this resolved? or still facing the issue???

      Delete
  5. Hi sakshi,
    i have been following your post and i like it but i don't know why every time tried to cross compile my Riotbord i have this error:

    Creating qmake...
    make: Nothing to be done for `first'.
    Running configuration tests...
    Failed to process makespec for platform 'devices/linux-imx6-g++'
    Project ERROR: Compiler /home/yassine/Desktop/fsl-linaro-toolchain/bin/arm-fsl-linux-gnueabig++ not found. Check the value of CROSS_COMPILE -device-option
    Could not read qmake configuration file /home/yassine/tools/rootfs/usr/local/qt-everywhere-opensource-src-5.1.1/qtbase/mkspecs/devices/linux-imx6-g++/qmake.conf

    please help me

    ReplyDelete
    Replies
    1. Hi Yassine,

      ERROR: Compiler /home/yassine/Desktop/fsl-linaro-toolchain/bin/arm-fsl-linux-gnueabig++ not found.

      Q1: Is your compiler stored in this path /home/yassine/Desktop/fsl-linaro-toolchain/bin/ ?
      Q2:/home/yassine/Desktop/fsl-linaro-toolchain/bin/arm-fsl-linux-gnueabig++ there should be a "-" in arm-fsl-linux-guneabi-g++ guess your config file is missing a "-"
      check once and try.

      Delete
  6. Hi sakshi,
    i have solved the problem of the compiler, thanx for the help anyway :) .
    Unfortenately, now i have a problem with the PKG_CONFIG_LIBDIR :
    when i tried to do "./config.imx6" i get this error :
    Creating qmake...
    make: Nothing to be done for `first'.
    Running configuration tests...
    Error: PKG_CONFIG_LIBDIR has not been set. This could mean
    the host's .pc files will be used (even if you set PKG_CONFIG_PATH).
    Set this variable to the directory that contains target .pc files
    for pkg-config to function correctly when cross-compiling or
    use -force-pkg-config to override this test.
    I used -force-pkg-config but nothing changed.
    I really don't know what is the problem !!
    Another question is this folder "/tools/rootfs" must be exist by default or i must create it ? because i didn't found it any where so i ceate it !
    I'm really bvery confused :( .
    Help me please.
    Regards.

    ReplyDelete
    Replies
    1. /tools/rootfs: It is the file system of the target. I am configuring in a way that compiled QT should be installed in the target's filesystem
      export the PKG_CONFIG_LIBDIR {Target filesystem=/tools/rootfs}/usr/lib/pkgconfig/

      Delete
    2. No it is not, so i created /tools/roots to save the same configuration and i this path i created the folder usr which is contains two folders "lib" and "include" copied from the system.
      But i think what i have done is not correct!

      Delete
    3. Another issue why PKG_CONFIG_LIBDIR-have no path? and if my changes does not work what shoulds i have to do?

      Delete