embedding qt

Download Embedding Qt

If you can't read please download the document

Upload: fscons

Post on 16-Apr-2017

2.829 views

Category:

Technology


0 download

TRANSCRIPT

Embedding Qt

A workshop in running Qton embedded Linux targets

Johan Thelin

Books, articles, whitepapers, tutorials

Training (embedded Linux, etc)

Various embedded Qt-based products

Qt mentoring

Networking (human to human)

Founder and moderator at QtCentre

Looking for Qt jobs related to Formula 1!

Two minutes of Qt

Developed since 1991

Licensing controversy 1998

GPL since 2005 (X11 2000, OS X 2003)

LGPL on all platforms since 2008

Trolltech was bought by Nokia 2008, renamed to Qt Software Qt Development Frameworks.

We call them Qt, and the developers are trolls.

Two minutes of Qt

Desktop: Windows, OS X and X11

Goal: native applications from one sourceGLIB integration

Styling, etc

Embedded: Windows CE, Symbian S60, Linux

100+ million devices out there!

The Qt Community

An open development model

Developer blogs: labs.trolltech.com

planetqt.org

Forums, wikis, IRC channels:qtcentre.org forum, wiki, news

qtnode.net #qt on freenode, wiki

Much more...

Workshop

Compiling compiling compiling compiling

Compiling

Compiling compiling compiling

Compiling compiling compiling compiling

Compiling compiling compiling

Compiling compiling

Compiling compiling compiling

Compiling compiling compiling compiling

Compiling compiling compiling

Workshop

Background a common development setup

Getting the source

Configuring and building for X11

Working with multiple installs of Qt and QMake

Configuring and building for QVFb

Embedded Linux 101

Configuring Qt for Embedded Linux

Deploying Qt on an embedded Linux target

Testing the Development Setup

The Development Setup

The setup consists of three installations of QtQt for X11 runs on host, used for tools.

Qt for QVFb runs on host with emulated devices

Qt for target runs on target, the real deal.

QVFb Qt Virtual Framebuffer lets youPrototype

Emulate for simplified debugging

Great for screenshots for manuals and designers

Getting the Sources

Sources are found at qt.nokia.com/downloads

Getting the Sources

Or you grab a snapshot from qt.gitorious.org

Getting the Sources

I have a USB stick with tar.gz-archives for today

Use Embedding\ Qt/*

$ ./configure --helpUsage: configure [-h] [-prefix ] [-prefix-install] [-bindir ] [-libdir ] [-docdir ] [-headerdir ] [-plugindir ] [-datadir ] [-translationdir ] [-sysconfdir ] [-examplesdir ] [-demosdir ] [-buildkey ] [-release] [-debug] [-debug-and-release] [-developer-build] [-shared] [-static] [-no-fast] [-fast] [-no-largefile] [-largefile] [-no-exceptions] [-exceptions] [-no-accessibility] [-accessibility] [-no-stl] [-stl] [-no-sql-] [-sql-] [-plugin-sql-] [-system-sqlite] [-no-qt3support] [-qt3support] [-platform] [-D ] [-I ] [-L ] [-help] [-qt-zlib] [-system-zlib] [-no-gif] [-qt-gif] [-no-libtiff] [-qt-libtiff] [-system-libtiff] [-no-libpng] [-qt-libpng] [-system-libpng] [-no-libmng] [-qt-libmng] [-system-libmng] [-no-libjpeg] [-qt-libjpeg] [-system-libjpeg] [-make ] [-no-make ] [-R ] [-l ] [-no-rpath] [-rpath] [-continue] [-verbose] [-v] [-silent] [-no-nis] [-nis] [-no-cups] [-cups] [-no-iconv] [-iconv] [-no-pch] [-pch] [-no-dbus] [-dbus] [-dbus-linked] [-no-separate-debug-info] [-no-mmx] [-no-3dnow] [-no-sse] [-no-sse2] [-qtnamespace ] [-qtlibinfix ] [-separate-debug-info] [-armfpa] [-no-optimized-qmake] [-optimized-qmake] [-no-xmlpatterns] [-xmlpatterns] [-no-phonon] [-phonon] [-no-phonon-backend] [-phonon-backend] [-no-openssl] [-openssl] [-openssl-linked] [-no-gtkstyle] [-gtkstyle] [-no-svg] [-svg] [-no-webkit] [-webkit] [-no-scripttools] [-scripttools]

[additional platform specific options (see below)]

Configuring Qt for X11

And then there are the undocumented switches...

$ ./configure --helpUsage: configure [-h] [-prefix ] [-prefix-install] [-bindir ] [-libdir ] [-docdir ] [-headerdir ] [-plugindir ] [-datadir ] [-translationdir ] [-sysconfdir ] [-examplesdir ] [-demosdir ] [-buildkey ] [-release] [-debug] [-debug-and-release] [-developer-build] [-shared] [-static] [-no-fast] [-fast] [-no-largefile] [-largefile] [-no-exceptions] [-exceptions] [-no-accessibility] [-accessibility] [-no-stl] [-stl] [-no-sql-] [-sql-] [-plugin-sql-] [-system-sqlite] [-no-qt3support] [-qt3support] [-platform] [-D ] [-I ] [-L ] [-help] [-qt-zlib] [-system-zlib] [-no-gif] [-qt-gif] [-no-libtiff] [-qt-libtiff] [-system-libtiff] [-no-libpng] [-qt-libpng] [-system-libpng] [-no-libmng] [-qt-libmng] [-system-libmng] [-no-libjpeg] [-qt-libjpeg] [-system-libjpeg] [-make ] [-no-make ] [-R ] [-l ] [-no-rpath] [-rpath] [-continue] [-verbose] [-v] [-silent] [-no-nis] [-nis] [-no-cups] [-cups] [-no-iconv] [-iconv] [-no-pch] [-pch] [-no-dbus] [-dbus] [-dbus-linked] [-no-separate-debug-info] [-no-mmx] [-no-3dnow] [-no-sse] [-no-sse2] [-qtnamespace ] [-qtlibinfix ] [-separate-debug-info] [-armfpa] [-no-optimized-qmake] [-optimized-qmake] [-no-xmlpatterns] [-xmlpatterns] [-no-phonon] [-phonon] [-no-phonon-backend] [-phonon-backend] [-no-openssl] [-openssl] [-openssl-linked] [-no-gtkstyle] [-gtkstyle] [-no-svg] [-svg] [-no-webkit] [-webkit] [-no-scripttools] [-scripttools]

[additional platform specific options (see below)]

Configuring Qt for X11

-prefix path -no-qt3support -nomake demos -nomake examples

Which edition of Qt do you want to use ?

Type 'c' if you want to use the Commercial Edition.Type 'o' if you want to use the Open Source Edition.

o

This is the Qt/X11 Open Source Edition.

You are licensed to use this software under the terms ofthe Lesser GNU General Public License (LGPL) versions 2.1.You are also licensed to use this software under the terms ofthe GNU General Public License (GPL) versions 3.

Type '3' to view the GNU General Public License version 3.Type 'L' to view the Lesser GNU General Public License version 2.1.Type 'yes' to accept this license offer.Type 'no' to decline this license offer.

Do you accept the terms of either license?

yes

Creating qmake. Please wait...

Configuring Qt for X11

Let this run through, then run make.

Multiple Qt Installs and QMake

QMake builds Makefiles (and projects, etcetera)Build a project file: qmake -project

Build a Makefile from a project file: qmake

For this, QMake knows aboutThe compiler to use

Paths and libraries to use

QMake is built when configuring Qt, so each Qt installation has a different QMake.

Multiple Qt Installs and QMake

project.procpphuiqrcqmake-x11qmake-targetqmake-qvfbMakefile+

Executable

Change qmake:

make distclean && qmake-nn

Building the QVFb

The QVFb tool is not built automatically when building Qt for X11.

cd tools/qvfbmakemake install

Configuring Qt for QVFb

Problem: The sources are extracted to qt-embedded-... . This is the same directory as will be used by the target sources.

Solution: Rename to qt-qvfb!

Configuring Qt for QVFb

$ ./configure --helpUsage: ...

[additional platform specific options (see below)]

...

Qt for Embedded Linux only:

-xplatform target ... The target platform when cross-compiling.

-no-feature- Do not compile in . -feature- .. Compile in . The available features are described in src/corelib/global/qfeatures.txt

-embedded .... This will enable the embedded build, you must have a proper license for this switch to work. Example values for : arm mips x86 generic

-armfpa ............. Target platform is uses the ARM-FPA floating point format. -no-armfpa .......... Target platform does not use the ARM-FPA floating point format.

The floating point format is usually autodetected by configure. Use this to override the detected value.

-little-endian ...... Target platform is little endian (LSB first). -big-endian ......... Target platform is big endian (MSB first).

-host-little-endian . Host platform is little endian (LSB first). -host-big-endian .... Host platform is big endian (MSB first).

You only need to specify the endianness when cross-compiling, otherwise the host endianness will be used.

-no-freetype ........ Do not compile in Freetype2 support. -qt-freetype ........ Use the libfreetype bundled with Qt. * -system-freetype .... Use libfreetype from the operating system. See http://www.freetype.org/

-qconfig local ...... Use src/corelib/global/qconfig-local.h rather than the default (full).

-depths ...... Comma-separated list of supported bit-per-pixel depths, from: 1, 4, 8, 12, 15, 16, 18, 24, 32 and 'all'.

-qt-decoration- ....Enable a decoration in the QtGui library, by default all available decorations are on. Possible values for : [ styled windows default ] -plugin-decoration- Enable decoration as a plugin to be linked to at run time. Possible values for : [ default styled windows ] -no-decoration- ....Disable decoration entirely. Possible values for : [ styled windows default ]

-no-opengl .......... Do not support OpenGL. -opengl ....... Enable OpenGL ES support With no parameter, this will attempt to auto-detect OpenGL ES 1.x or 2.x. Use es1, es1cl or es2 for to override auto-detection.

NOTE: A QGLScreen driver for the hardware is required to support OpenGL ES on Qt for Embedded Linux.

-qt-gfx- ... Enable a graphics in the QtGui library. Possible values for : [ linuxfb transformed qvfb vnc multiscreen ] -plugin-gfx- Enable graphics as a plugin to be linked to at run time. Possible values for : [ ahi directfb hybrid linuxfb powervr qvfb transformed vnc ] -no-gfx- ... Disable graphics entirely. Possible values for : [ linuxfb transformed qvfb vnc multiscreen ]

-qt-kbd- ... Enable a keyboard in the QtGui library. Possible values for : [ tty usb sl5000 yopy vr41xx qvfb ]

-plugin-kbd- Enable keyboard as a plugin to be linked to at runtime. Possible values for : [ linuxis sl5000 usb vr41xx yopy ]

-no-kbd- ... Disable keyboard entirely. Possible values for : [ tty usb sl5000 yopy vr41xx qvfb ]

-qt-mouse- ... Enable a mouse in the QtGui library. Possible values for : [ pc bus linuxtp yopy vr41xx tslib qvfb ] -plugin-mouse- Enable mouse as a plugin to be linked to at runtime. Possible values for : [ bus linuxis linuxtp pc tslib vr41xx yopy ] -no-mouse- ... Disable mouse entirely. Possible values for : [ pc bus linuxtp yopy vr41xx tslib qvfb ]

-iwmmxt ............ Compile using the iWMMXt instruction set (available on some XScale CPUs).

-no-glib ........... Do not compile Glib support. + -glib .............. Compile Glib support.

Configuring Qt for QVFb

-prefix path

-no-...

-nomake examples-nomake demos

-qt-freetype

-qt-zlib

-no-gif-qt-libjpeg-qt-libpng

-depths 8,16

-qt-kbd-qvfb-qt-mouse-qvfb-qt-gfx-qvfb

Use the same tricks as with Qt for X11

Use Qt's versions of 3rd party libraries

Depths limits you to what your target has-qt-*-qvfb builds with drivers for the virtual target

There are more options now configure and make

Embedded Linux 101

Linux kernelCan be pre-configured for the specific board to reduce boot time

Can contain all drivers (avoid loading modules)

Can contain parts or the full file system.

Same or smaller C libglibc works uclibc, newlib, etc are smaller

Fewer and smaller utilitiesbusybox replaces most tools

Avoid all extras (usually not shipping with emacs)

Embedded Linux 101

Different architecture means that you need to cross compile.

The entire system is usually built into one or a few binary images.Kernel + initial file system

Additional file systems

Use the available infrastructure!buildroot, scratchbox, openembedded, etc

Qt for Embedded Linux Dependencies

Graphics needs a framebufferCan acceleration, e.g. PowerVR (TI OMAP), DirectFB, etcetera.

Touch based input needs tslibtslib.berlios.org

You can provide custom Qt back-ends for graphics, mouse, keyboard.

Configuring Qt for Embedded Linux

No hardware here today, but lets target an imaginary ARM board.

Possible real targets for the curious:An old PC (or a newer one...)

BeagleBoard

AT91SAM9263-EK

Toradex Colibri

Configuring Qt for Embedded Linux

Use the same setup as for your QVFb

Prepare for an embedded target and a cross compilation

-prefix path

-no-...

-nomake examples-nomake demos

-qt-freetype

...

-depths 8,16

-embedded arch-xplatform mkspec

Configuring Qt for Embedded Linux

The arch names your target architecturex86, x86_64, ia64, arm, powerpc, mips, sh, sh4a

Gives you architecture specific implementations, e.g. qatomic_i386.h

Configuring Qt for Embedded Linux

The mkspec describes your build environment

...#define QT_SOCKET_BIND::bind#define QT_FILENOfileno#define QT_CLOSE::close#define QT_READ::read#define QT_WRITE::write#define QT_ACCESS::access#define QT_GETCWD::getcwd#define QT_CHDIR::chdir#define QT_MKDIR::mkdir#define QT_RMDIR::rmdir#define QT_OPEN_LARGEFILE O_LARGEFILE#define QT_OPEN_RDONLYO_RDONLY#define QT_OPEN_WRONLYO_WRONLY#define QT_OPEN_RDWRO_RDWR#define QT_OPEN_CREATO_CREAT#define QT_OPEN_TRUNCO_TRUNC#define QT_OPEN_APPENDO_APPEND

#define QT_SIGNAL_RETTYPEvoid#define QT_SIGNAL_ARGSint#define QT_SIGNAL_IGNORESIG_IGN

#if defined(__GLIBC__) && (__GLIBC__ >= 2)#define QT_SOCKLEN_Tsocklen_t...

...QMAKE_CC = arm-linux-gccQMAKE_CXX = arm-linux-g++QMAKE_LINK = arm-linux-g++QMAKE_LINK_SHLIB = arm-linux-g++

# modifications to linux.confQMAKE_AR = arm-linux-ar cqsQMAKE_OBJCOPY = arm-linux-objcopyQMAKE_STRIP = arm-linux-strip...

qmake.conf

qplatformdefs.h

Deploying Qt for Embedded Linux

What do you need to deploy?Your binary

Qt library

Qt plug-ins

Fonts

Environment variables

Command line arguments

Deploying Qt for Embedded Linux

Qt libraryPlace either according to -prefix,
or in LD_LIBRARY_PATH

Qt plug-insPlace according to -prefix,
or add a qt.conf file,
or call QApplication::addLibraryPath to add paths

FontsPlace either according to -prefix,
or point at using QT_QWS_FONTDIR

Deploying Qt for Embedded Linux

Environment variablesQWS_MOUSE_PROTO

QWS_KEYBOARD

QWS_DISPLAY

Command line arguments-qws

Testing the Environment

In the Qt for QVFb source tree, cd to examples/widgets/wiggly

Run qmake-qvfb* (specify full path) && make

Start QVFb and pick a skin

Start ./wiggly -qws

Enjoy!

For the brave and curious, try running

make distclean && qmake-x11 && make

./wiggly

* I like to create soft links to the different qmakes and name them qmake-x11, qmake-qvfb, etcetera

Thank you for your attention!

www.thelins.se

Workshop: Embedding Linux

Copyright(C)2009 Thelins Teknikkonsult