Zynq Qt and Qwt Base Libraries-Build Instructions


Table of Contents

1 Introduction


This wiki page summarizes the build steps for Qt 4.7.3 and Qwt 6.0.1 libraries as used in the Zynq Base TRD 2015.2 or older.
The Zynq Base TRD version 2015.4 uses Qt 5.4.2 and Qwt 6.1.2. Please refer to this wiki page for build instructions.

2 Prerequisites


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 Zynq Tools wiki page for more information on how to set up the tool chain and known issues.

Note: These instructions currently require a Linux host for building.

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

3 Cross-Compile Qt4 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.

3.1 Download the Qt Source Archive


Download the Qt sources and extract the 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

3.2 Prepare 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

Download the qmake configuration file from the link below to override the existing linux-arm mkspec.



bash> cp /path/to/downloaded/qmake_4.7.3.conf mkspecs/qws/linux-arm-gnueabi-g++/qmake.conf

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

3.3 Configure 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

3.4 Build and Install


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

4 Cross-Compile 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.

4.1 Download the Qwt Source Archive


Download the Qwt sources and extract the 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

Note: Make sure you configure, compile and install the qwt libraries in the same shell as the Qt installation as some Qt environment variables are reused for this build.

4.2 Configure 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.

Download the config file from below and replace the existing one.



bash> cp /path/to/downloaded/qwtconfig_6.0.1.pri qwtconfig.pri bash> qmake qwt.pro

4.3 Build and Install


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

5 Add 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

6 Create a File System Image with Pre-Compiled Qt/Qwt Libraries


NOTE: This step is optional and is needed for Zynq Base TRD 14.x version for copying QT libraries on a formatted ext2 filesystem.
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

7 Web Sources

8 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.

© Copyright 2019 - 2022 Xilinx Inc. Privacy Policy