Zynq Qt/Qwt Libraries - Build Instructions

1 Prerequisites

1.1 Setting up the Environment

This tutorial requires the ARM GNU tools, which are part of the Xilinx Software Development Kit (SDK), to be installed on your host system. Specify the ARM cross-compiler by setting the CROSS_COMPILE environment variable and adding the cross-compiler to your PATH. Refer to the ARM GNU Tools wiki page for more information on how to set up the tool chain and known issues.

bash> export CROSS_COMPILE=arm-xilinx-linux-gnueabi-
bash> export PATH=/path/to/cross/compiler/bin:$PATH

For simplicity we define two environment variables in this tutorial:

  • ZYNQ_QT_BUILD refers to the Qt build area
  • ZYNQ_QT_INSTALL refers to the Qt install area
bash> export ZYNQ_QT_BUILD=/path/to/qt/build
bash> export ZYNQ_QT_INSTALL=/path/to/qt/install
bash> export PATH=$ZYNQ_QT_INSTALL/bin:$PATH

1.2 Extracting the Zynq Qt/Qwt Sources Archive

Download the Qt/Qwt sources archive and extract it to your Qt build area.

bash> cp qt_build_src.tar $ZYNQ_QT_BUILD
bash> cd $ZYNQ_QT_BUILD
bash> tar xfv qt_build_src.tar

The archive contains the following files:

  • qt-everywhere-opensource-src-4.7.3.tar.gz – Qt source archive
  • qmake.conf – Qt qmake configuration file
  • qwt-6.0.1.tar.bz2 – Qwt source archive
  • qwtconfig.pri – Qwt qmake project include file

2 Cross-Compiling Qt for Embedded Linux

Qt for Embedded Linux is a C++ framework for GUI and application development for embedded devices. It runs on a variety of processors, usually with Embedded Linux. Qt for Embedded Linux provides the standard Qt API for embedded devices with a lightweight window system. Qt for Embedded Linux applications write directly to the framebuffer, eliminating the need for the X Window System and saving memory.

qt-embedded-linux-architecture.png

2.1 Extracting the Qt Source Archive

Extract the Qt source archive to your Qt build area.

bash> cd $ZYNQ_QT_BUILD
bash> tar xzfv qt-everywhere-opensource-src-4.7.3.tar.gz
bash> cd qt-everywhere-opensource-src-4.7.3

2.2 Preparing a mkspec

Before we can do the configuration for the target system, we will need a set of mkspecs that tells qmake which tool chain it should reference when it creates the Makefiles. In this example we will provide an mkspec to go along with the ARM GNU tools.

The mkspec consists of two files:

  • qmake.conf – This is a list of qmake variable assignments that tells qmake what flags to pass through to the compiler, which compiler to use etc
  • qplatformdefs.h – This is a header file with various platform-specific #includes and #defines. Often this just refers to an existing qplatformdefs.h file from another generic mkspec

Copy the provided qmake.conf to the mkspec/qws/linux-arm-gnueabi-g++ sub-directory in the Qt build area.

bash> cp $ZYNQ_QT_BUILD/qmake.conf mkspecs/qws/linux-arm-gnueabi-g++

The corresponding qplatformdefs.h file just refers to an existing generic one, so nothing needs to be done here.

2.3 Configuring the Target Build

We are now ready to configure Qt to use our mkspec and hence use our cross-compiling toolchain.

bash> ./configure \
       -embedded arm \
       -xplatform qws/linux-arm-gnueabi-g++ \
       -little-endian \
       -opensource \
       -host-little-endian \
       -confirm-license \
       -nomake demos \
       -nomake examples \
       -prefix $ZYNQ_QT_INSTALL

Here is some information on some of the options that appear:

  • -xplatform <mkspec files to use> – Cross compile for the target platform using the environment specified in the mkspec files
  • -embedded <target CPU architecture> – The CPU architecture of the target platform
  • -prefix <path> – The path to install the cross-compiled Qt to
  • -confirm-license – Lazy option to save agreeing to license agreement during configure process

2.4 Building and Installing

Run make to build the cross-compiled target version of Qt.

bash> make

Once the build has completed it is time to install Qt. You may need to su to root to do this part depending upon what prefix you configured the build with.

bash> su -          #if you need root access to be able to install
bash> make install

3 Cross-Compiling Qwt – Qt Widgets for Technical Applications

The Qwt library contains GUI Components and utility classes which are primarily useful for programs with a technical background. Beside a 2D plot widget it provides scales, sliders, dials, compasses, thermometers, wheels and knobs to control or display values, arrays, or ranges of type double.

3.1 Extracting the Qwt Source Archive

Extract the Qwt source archive to your Qt build area.

bash> cd $ZYNQ_QT_BUILD
bash> tar xjfv qwt-6.0.1.tar.bz2 
bash> cd qwt-6.0.1

3.2 Configuring the Build using qmake

Projects are described by the contents of project files (.pro). Files that end with the suffix .pri are included by the project files and contain definitions that are common for several project files. The information within these is used by qmake to generate a Makefile containing all the commands that are needed to build each project.

bash> cp $ZYNQ_QT_BUILD/qwtconfig.pri .
bash> qmake qwt.pro

3.3 Building and Installing

Run make to build the cross-compiled target version of Qwt.

bash> make

Once the build has completed it is time to install Qwt. You may need to su to root to do this part depending upon what prefix you configured the build with.

bash> su -          #if you need root access to be able to install
bash> make install

4 Adding the GNU Standard C++ Library

In order to build and run your Qt application, the GNU Standard C++ Library of the ARM GNU Tools needs to be copied to the Qt install area's lib directory.

bash> cp -P /path/to/cross/compiler/arm-xilinx-linux-gnueabi/libc/usr/lib/libstdc++.so* \ 
            $ZYNQ_QT_INSTALL/lib

5 Creating a File System Image with Pre-Compiled Qt/Qwt Libraries

The final step shows how to create an image file of the Qt install area that can be copied onto an SD card and then mounted on the target system. These libraries are required to run the Qt application on the target system. First we create an empty image file of size 80MB, then we format the image with the ext2 file system.

bash> cd $ZYNQ_QT_BUILD
bash> dd if=/dev/zero of=qt_lib.img bs=1M count=80
bash> mkfs.ext2 -F qt_lib.img

Now we just need to mount the image on our host machine, copy over the libraries from the Qt install area and we are done. You may need to su to root to do this part.

bash> su -                            #if you need root access to be able to install
bash> chmod go+w qt_lib.img
bash> mount qt_lib.img -o loop /mnt
bash> cp -rf $ZYNQ_QT_INSTALL/* /mnt
bash> chmod go-w qt_lib.img
bash> umount /mnt

6 Web Sources

Qt for Embedded Linux Reference Documentation
Qwt - Qt Widgets for Technical Applications User's Guide

7 Licensing

All files provided by Xilinx may be used under the terms of the GNU General Public License (GPL) version 3.0. Please refer to Qt License Options and Qwt License Version 1.0 for details.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License