Qtopia Home - Classes - Hierachy - Annotated - Functions - Qt Embedded

Qtopia Single Exec

Introduction

Qtopia can be compiled in a number of ways. The standard way is a fully dynamic build where each application is a separate binary run as a separate process. There is also another way to compile Qtopia, and that is the single-exec way. This kind of build is a single binary, qpe and all the applications are linked together in to a single large binary, however applications are still run as separate processes.

Benefits

There are a number of benefits to single-exec.

Explanation

The main idea behind single-exec is to make it possible to statically link the libraries to the programs. Normally if you did this, the size would be massive, each application having a copy of all the libraries. But by compiling all the application code in to the one binary, this is not a problem. Normally if one did this, you might just have one process, and in that process create new top level widgets of the different applications within that process, but this is not a very stable model, a single application fault brings down the whole system. Therefore it is necessary to run the applications as separate processes.

How it works

When we start a new application in single-exec, we fork the server process, and exec the same binary again, but with an argv list that will inform the newly created process what application it should be. This model is very similar to that used by a UNIX tool called busybox which morphs in to different programs based on argv[0].

The size benefit of single-exec comes from static linking. When the linker combines together the code, it can do various size optimizations such as removing inline functions that are always included inline or removing redundant or dead code that is not used by any of the applications, as well as not needing to include symbol tables usually needed for dynamic linking. Additionally the code does not need to be PIC (position independent code) which gives additional size and speed gains.

Catches

One important thing to be aware of when building single-exec with additional 3rd party components is that the symbols can not clash with those from other applications, use of C++ namespaces would be a very good idea to avoid potential problems caused by this.

Building single-exec

To build Qtopia as a single-exec binary, configure and build Qtopia normally with just the addition of -singleexec to the options passed to Qtopia's configure script. The result will be that no application binaries or plugins will be generated, instead, the qpe binary will be larger than before, but contains all the code that would have been in the other binaries. Additionally if you also wish to statically link the Qt/Embedded, Qtopia and 3rd party libraries, add -static to the arguments passed to the Qt/Embedded and Qtopia configure scripts.


Copyright © 2001-2005 Trolltech Trademarks
Qtopia version 2.1.1