Building Qt
Overview
This document follows on from the document entitled Yocto for TW, which explains how to configure the host and build Yocto.
Building Qt5 Libraries
Download Files
$ cd /tmp
$ wget http://www.noritake-itron.com/downloads/Qt_install.tar.gz$ wget
http://download.qt.io/archive/qt/5.4/5.4.1/single/qt-everywhere-opensource-src-5.4.1.tar.gz
Building the SDK
Extract the SDK and run the install script using the default location /opt/poky/1.7.2
$ tar -zxvf Qt_install.tar.gz
$ /tmp/qt_install/poky-glibc-x86_64-core-image-minimal-armv5te-toolchain-1.7.2.sh
Initial Setup
Extract the Qt source code.
$ mkdir ~/src
$ cd ~/src
$ tar xvf /tmp/qt-everywhere-opensource-src-5.4.1.tar.gz
Create a git repository for the Qt source code.
$ cd ~/src/qt-everywhere-opensource-src-5.4.1
$ git init
$ git add .
$ git commit -m "Initial import"
Apply the mkspecs patch found in qt_install.tar.gz
$ git am /tmp/qt_install/0001-mkspecs-for-poky-SDK-toolchain.patch
Configure and Compile
$ export PATH=/opt/poky/1.7.2/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/:$PATH
Prepare the Qt build by running the configure script enabling any additional configuration options that you need.
$ ./configure -qpa linuxfb -xplatform poky-arm-gnueabi-g++ -opensource -confirm-license -release -nomake tests -tslib -prefix /opt/qt5-itron -no-pch -no-xcb -sysroot /opt/poky/1.7.2/sysroots/armv5te-poky-linux-gnueabi/ -no-opengl -no-openssl -no-libudev -no-fontconfig
After Qt has been configured compile it using the make command. The ‘j4’ option tells the compiler to use 4 cores. This can be changed if you have more or less cores available.
$ make -j4
Once compiling is finished you need to install it.
$ sudo make install
This process will generate two sets of files, the first (/opt/qt5-itron) is used to cross compile applications for Qt, the second (/opt/poky/1.7.2/sysroots/armv5te-poky-linux-gnueabi/opt/qt5- itron) is the Qt library which must be copied to the rootfs on the target display. This allows the display to run a Qt application.
Copy Library to Target
Compress the Qt library and extract into the rootfs on the target display. This will copy the Qt libraries on to the SD card ready for use on the display.
$ sudo tar cvf qt5-itron.tar.gz qt5-itron
$ sudo mkdir /media/itron/1052d0d1-bc61-40fc-9cc6-2289c5aa7dd9/opt
Extract the tar onto the 'opt' directory of your SD card, in the case of this example the opt directory was located in '/media/itron/1052d0d1-bc61-40fc-9cc6-2289c5aa7dd9/opt' replace this with your own.
$ sudo tar xvf qt5-itron.tar.gz -C /media/itron/1052d0d1-bc61-40fc-9cc6- 2289c5aa7dd9/opt
Cross Compiling Qt Project
Now you can compile your Qt project for use on the target display using the command line. Download the example Elevator Qt project found at http://www.itrontft.com/ This project can be edited in the Qt Creator which can be downloaded from the official Qt website. Note that when creating a new project in Qt Creator QtQuick 2.0 or above will not work because the display does not support OpenGL.
Initial Setup
$ export PATH=/opt/poky/1.7.2/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/:/opt/qt5-itron/bin:$PATH
Locate the Elevator project directory, here we have used example as the project name.
$ cd Elevator
$ qmake
$ make
Make will generate a cross compiled binary ready for the target display. Copy this onto the file system on your SD card. Here we will copy the binary to '/home/root'.
$ cp Elevator /media/itron/1052d0d1-bc61-40fc-9cc6-2289c5aa7dd9/home/root/
Running a Qt Application
Boot the display from the SD card and login as root. You will then be able to run the binary using the touch device on event1.
$ ./Elevator -plugin tslib:/dev/input/event1