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 :):)