/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file.  Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
    \page windowsce-customization.html
    \ingroup qtce
    \title Windows CE - Working with Custom SDKs
    \brief How to set up Qt for use with custom Windows CE SDKs.

    When working with a custom SDK for Windows CE, Qt provides an easy way
    to add support for it to your development environment. The following is
    a tutorial that covers how to create a specification for Qt for Windows
    CE platforms.

    \tableofcontents

    \section1 Creating a Custom Build Specification

    Create a subdirectory in the \c mkspecs folder of the Qt directory.
    New specifications for Qt for Windows CE following this naming convention:

    \snippet snippets/code/doc_src_wince-customization.qdoc 0

    Using this convention makes it possible for \l{qmake} to identify that
    you are building Qt for Windows CE, and will customize the compilation
    process accordingly.

    Create the files \c qmake.conf and \c qplatformdefs.h inside the new
    specification directory. Take a look at the implementation of the other
    Windows CE specifications included in the \c mkspecs directory to see
    what is required to build Qt for Windows CE successfully.


    \section1 Fine-Tuning Options

    Compared to the desktop versions, Qt for Windows CE needs two additional
    options:

    \list
    \li \b{CE_SDK} specifies the name of the SDK.
    \li \b{CE_ARCH} specifies information about the target architecture.
    \endlist

    Following is an example configuration for a custom SDK we call "CustomSDK":

    \snippet snippets/code/doc_src_wince-customization.qdoc 1

    \note Running \l qmake to generate Visual Studio project files for Windows CE currently does not produce valid output..

    Additionally, most Windows CE SDKs use extra compiler options. These
    can be specified by expanding the \c DEFINES value.

    For example, with CustomSDK, the \c DEFINES variable
    is expanded in the following way:

    \snippet snippets/code/doc_src_wince-customization.qdoc 2


    \section1 Cross-compilation Environment for a Custom SDK

    Qt for Windows CE only requires that the mkspec that is specified
    with -xplatform is setup as mentioned \l{Fine-Tuning Options}{above}.

    The selection of the custom SDK environment will happen by concatenating \c CE_SDK
    and \c CE_ARCH. This builds a string that can be found in "\e{%ProgramFiles%\\Microsoft Visual Studio 9.0\\VC\\vcpackages\\WCE.VCPlatform.xml}"
    and contains the correct environment. If you are unsure about the SDK name and Arch for your
    SDK you can find it in this file.


    \section1 Compiling Qt for a Custom SDK

    Windows CE is highly customizable, hence it is possible that some SDKs have
    feature-stripped setups. Depending on the SDK's configuration, Qt may not
    compile in its standard configuration, as Qt for Windows CE is designed to
    be compatible with the Standard SDK setup. Every Makefile qmake generates
    that is not flagged to build for the host system will build WindowsCE projects
    for the SDK Qt was built with. There is no need to set a custom environment
    besides the Visual Studio 2005/2008 environment.

    However, it is possible to exclude features of Qt and create a version that
    compiles for the desired SDK.

    \section1 Making Qt Applications Start on a Custom Device

    Sometimes, a Windows CE device has been created with a configuration
    different from the corresponding SDK's configuration. In this case, symbols
    that were available at linking stage will be missing from the run-time
    libraries.

    Unfortunately, the operating system will not provide an error message that
    mentions which symbols are absent. Instead, a message box with the following
    message will appear:

    \c{app.exe is not a valid CE application!}

    To identify the missing symbols, you need to create a temporary
    application that attempts to dynamically load the Qt for Windows CE
    libraries using \c LoadLibrary. The following code can be used for this:

    \snippet snippets/code/doc_src_wince-customization.cpp 9

    Once you have compiled and deployed the application as well as the Qt
    libraries, start a remote debugger. The debugger will then print the
    ordinal number of the unresolved symbol.

    Search for parts of Qt that rely on these functions and disable them using
    the QFeatures functionality.

    In our experience, when Qt applications do not start on Windows CE, it is
    usually the result of missing symbols for the following classes or
    features:
    \list
    \li \l{Drag and Drop}
    \li \l{QClipboard}
    \li \l{QCursor}
    \endlist

    Please refer to the Microsoft documentation
    \l{http://msdn.microsoft.com/en-us/library/e7tsx612.aspx}{here} for
    information on what ordinals are and how you can create them. Information
    on accessing the corresponding symbol name to a given ordinal value can
    also be found in the Microsoft documentation.

*/

/*!
    \page shadow builds-wince.html
    \ingroup qtce
    \title Windows CE - Using shadow builds
    \brief How to create a shadow build for Qt for Windows CE.

    \tableofcontents

    While developing for Windows CE you might want to compile a
    version of Qt for several different platforms and SDKs. In order
    to create those different builds of Qt you do not have to copy the
    whole Qt package or the Qt source. You are able to create multiple
    Qt builds from a single source tree. Such builds are called shadow
    builds.

    Basically a shadow build is created by calling configure.exe from a
    different directory.

    To make sure that the shadow build compiles correctly it is important
    that you following these guidelines:

    \list
    \li The original Qt source package must be left untouched - configure must
    never have been run in the source tree directory.

    \li With Qt5, the code has to be checked out of the git repository, otherwise
        the out of source build will fail as syncqt is not executed.
    \li Avoid using "release" and "debug" in the path to the shadow build
    directory. (This is an internal limitation of the build system.)
    \li Perl has been installed on your system. (\l{ActivePerl} is a popular
    distribution of Perl on Windows.)
    \endlist

    So lets assume you have installed Qt in \c{C:\Qt\5.4.0} and you want
    to create a shadow build in \c{C:\Qt\mobile5-shadow}:

    \list

    \li Make sure the environment variables for your compiler are set.

    Visual Studio includes \c{vcvars32.bat} for that purpose - or simply use
    the "Visual Studio Command Prompt" from the Start menu.

    \li Now navigate to your shadow build directory and run configure:

    \snippet snippets/code/doc_src_wince-customization.qdoc 4


    \li Finally, to build the shadow build type:

    \snippet snippets/code/doc_src_wince-customization.qdoc 7

    \li That's all. You have successfully created a shadow build of Qt in
    \c{C:\Qt\mobile5-shadow}.

    \li Now you can call \c{nmake install} and get a clean installation of Qt
        in \e{%INSTALLDIR%}.
    \endlist
*/
