Home · Reference · User Guide · Internals

Applications

Qtopia applications can be built in one of four ways.

To facilitate switching between build modes, two macros are provided. They are to be used as follows:

    #include "myheader.h"
    #include <QtopiaApplication>

    QTOPIA_ADD_APPLICATION(QTOPIA_TARGET,MyMainClass)
    QTOPIA_MAIN

The first argument to QTOPIA_ADD_APPLICATION() must be a literal string that matches the binary name (ie. the value of TARGET from the .pro file). The build system defines QTOPIA_TARGET with the value of TARGET and it is recommended to use this macro.

The second argument to QTOPIA_ADD_APPLICATION() should be the name of your class. If you use the wrong value you will get a compile failure.

Building for either quicklaunch or singleexec (quicklaunch) requires these macros but the build system cannot easily tell if you have used them and the penalty for a wrong guess could be disastrous. Therefore you must use the qtopia_main CONFIG value if you use these macros or the build system will assume your app is not quicklaunch-compatible. If your app does not handle quicklaunch or singleexec you can use the no_quicklaunch or no_singleexec CONFIG values.

For example, games don't need the speed benefits of quicklauncher (and there's a size penalty for using quicklauncher) but they do work with singleexec so they do CONFIG+=qtopia_main no_quicklaunch to indicate this.

Some applications cannot use the macros (eg. If you need to use a custom application class). This prevents the use of quicklauncher but you can still work with singleexec if you make some changes to your code. You need to use the singleexec_main CONFIG value and have a main.cpp that looks something like this:

    #include "myheader.h"
    #include <QtopiaApplication>

    #ifdef SINGLE_EXEC
    QTOPIA_ADD_APPLICATION(QTOPIA_TARGET,MyMainClass)
    #define MAIN_FUNC main_MyMainClass
    #else
    #define MAIN_FUNC main
    #endif

    int MAIN_FUNC( int argc, char **argv )
    {
        MyApplication a( argc, argv );
        MyMainClass w;
        w.show();
        return a.exec();
    }

The use of MyMainClass is not strictly required but the value you use must be unique.

See also qtopia_main, no_quicklaunch, singleexec_main, no_singleexec, and QTOPIA_TARGET.


Copyright © 2007 Trolltech Qtopia Build System Documentation