Projects/KDE on Windows/Windows CE

< Projects‎ | KDE on Windows
Revision as of 17:25, 8 December 2009 by Aheinecke (Talk | contribs)

Jump to: navigation, search

Contents

Introduction

This page describes a work in progress, there are no KDE Applications running on Windows Mobile (that I know of). It is only intended to give a starting point to developers for cross compilation and Windows CE related issues. Since Qt is already ported for Windows CE it should be possible to get some KDE applications running on that Platform.

Building Qt for Windows CE with MSVC

Setting up Visual Studio

First thing you need is Visual Studio professional or standard edition (preferably with service pack 1). Be aware that the express editions are explicitly not supported for Windows CE development.
(You could use Microsoft Embedded VC which is cost-free, but depreciated and not supported by Qt)
Next thing you need is a Microsoft Windows Mobile Platform SDK corresponding to your target platform. Just search the Microsoft download pages or get the Windows Mobile 6 SDK from here (You should take a loot at the System Requirements)
If everything is set up correctly you should now be able to create a “Visual C++ smart device" project in Visual Studio.


Building Qt

Download the Qt libraries for Windows CE from http://qt.nokia.com/downloads/win-ce-cpp and extract it, you may want to make sure that your path contains no blanks to avoid some problems.
Now you should add your <qt-directory>\bin to your Windows PATH environment variable (which can be done from “Control Panel → System → Advanced →Environment variables” )

Next get up your Visual Studio Command Prompt which should be accessible from the Windows Start Menu. Change the working directory to qt-directory and start the configuration. There should be a configuration.exe in your qt-directory with the usual options, (configure.exe -help for more info) for cross compiling you need to give at least the -platform parameter with your host system and -xplatform with your cross-compile target. Supported platforms are listed in the README file. e.g.:

configure.exe -platform win32-msvc2008 -xplatform wincewm60standard-msvc2008

Now that your configuration is set you can start the cross compilation. To switch from your “normal” build environment to the wince target Qt has a nice script included in the /bin directory (which should be in your PATH) just try calling setcepaths and provide your target configuration.
setcepaths wincewm60standard-msvc2008
With nmake (Visual Studio version of make) you can now build Qt for your target system.


Building Qt for Windows CE with CeGCC

Getting CeGCC

CeGCC (http://cegcc.sourceforge.net/) is a free cross-development environment for ARM-based systems running Windows CE. It is not officially supported by Qt and work with it is highly experimental, but given some work it could be possible to use it to build KDE-applications for Windows Mobile.

You can get CeGCC here: http://sourceforge.net/projects/cegcc/files/cegcc/0.59.1/mingw32ce-0.59.1.tar.bz2/download
Or to build the latest Version yourself see: http://cegcc.sourceforge.net/docs/build-toolchain.html


Building Qt

Maurice Kalinowski at Nokia did some work on this and provided a working Qt-Version with make specs for mingw32ce that make it possible to build most of the Qt parts. The original mailing-list thread discussing this can be found here: http://lists.trolltech.com/pipermail/qt-wince-interest/2009-November/000764.html

Link to the gitorious repository: http://gitorious.org/+qt-developers/qt/ce-gcc

After downloading you should take a look at the cegcc_configure script, maybe change the installation prefix there and then execute it. If your configuration fails make sure that your environment is not yet set for cross-compiling.

When configuration is complete you can build the host-tools, just go into your checkout and execute:
{

       QTCEDIR=$(pwd)
       folders="bootstrap moc uic rcc"
       for f in $folders; do
           cd $QTCEDIR/src/tools/$f && $QTCEDIR/bin/qmake -spec $QTCEDIR/mkspecs/linux-g++ && make && cd $QTCEDIR || return
       done

}

If the tools were built you now need to set up your environment for cross-compiling.

        export MINGWPATH=/opt/mingw32ce
        export INCLUDE=$MINGWPATH/arm-mingw32ce/include:$MINGWPATH/include:$INCLUDE
        export LIB=$MINGWPATH/arm-mingw32ce/lib:$MINGWPATH/lib:$LIB
        export PATH=$MINGWPATH/bin:$MINGWPATH/arm-mingw32ce/bin:$MINGWPATH/libexec/gcc/arm-mingw32ce/4.4.0:$PATH

Of course you have to change MINGWPATH according to your installation.

Now all that is left to do is to build Qt for the target system, to do that (again from your checkout directory) execute:
{

       QTCEDIR=$(pwd)
       folders="winmain corelib gui"
       for f in $folders; do
           cd $QTCEDIR/src/$f && $QTCEDIR/bin/qmake && make && make install && cd $QTCEDIR || return
       done

}


Notes:

- in case of pch errors delete .pch/release-static-emb-windowsce/qt_gui_pch.h.gch directory

- when you are compiling your application outside of the Qt tree, you might get into trouble related to mkspecs and include dirs.

- for deployment you need to copy these files also to the same directory on the device:

   libgcc_s_sjlj-1.dll
   libstdc++-6.dll
 which are located inside the arm-mingw32ce directory

- Currently Windows Mobile > 6.0 does not load the libgcc_s_sjlj-1.dll libstdc++-6.dll properly, but a fix is in the works, see:

http://www.mail-archive.com/cegcc-devel@lists.sourceforge.net/msg02699.html



Packaging:

Deploying Qt Windows Mobile Applications using LCAB

LCAB is a free software utility, that has the ability to create Microsoft CAB archives. You can get it on ( http://packages.debian.org/lenny/lcab )or as a Debian package.

Now that you can create cabinet files, the question is how to get Windows Mobile to recognize them as install packages. Thanks to Shaun Jackman this, also is no Problem. He wrote a Perl script to add the needed manifest and setup configuration file. You can find it under ( http://files.intevation.de/incoming/aheinecke/cab_files/pocketpc-cab.pl ) There is also a pocketpc-cab Debian packet out there, which does not support registry entries or the creation of shortcuts.

This script needs a configuration file, like Cabwiz but it is much more simple then the Cabwiz variant. Simply write down for every file you want to package:

Filename Target-Directory [Shortcut Name] [Shortcut Folder] for example the Qt widget collidingmice: collidingmice.exe %CE1%/Colliding_Mice "Colliding Mice" %CE11% msvcr90.dll %CE2% QtCore4.dll %CE2% QtGui4.dll %CE2%

This installs collidingmice.exe to Program Files/Colliding_Mice , places a shortcut in the Start Menu folder and copies the libraries into the Windows directory.

CE Variables

Here are some predefined Windows CE variables which can be used to identify a path on a Windows CE device.

      %CE1%	\Program Files
      %CE2%	\Windows
      %CE4%	\Windows\StartUp
      %CE5%	\My Documents
      %CE6%	\Program Files\Accessories
      %CE7%	\Program Files\Communication
      %CE8%	\Program Files\Games
      %CE11%	\Windows\Start Menu\Programs
      %CE12%	\Windows\Start Menu\Programs\Accessories
      %CE13%	\Windows\Start Menu\Programs\Communications
      %CE14%	\Windows\Start Menu\Programs\Games
      %CE15%	\Windows\Fonts
      %CE17%	\Windows\Start Menu

Deploying Qt Windows Mobile Applications using Cabwiz

Maybe in some situations Cabwiz has its relevance, (e.g. you only want to build from windows) but even then i would suggest to directly edit the setup.xml that is included in the Cabinet file. This should be easier then working with Cabwiz to generate the setup.xml

Microsoft Cabwiz is part of Microsofts Windows Mobile SDKs

I will try to demonstrate the usage of Cabwiz and the inf file format by creating a small configuration example to install the Qt example Tetrix, which comes as part of the Qt package, on a Windows Mobile Device.

If you built Qt using msvc you need to deploy 4 files to the Windows CE device:

       Tetrix.exe      ; the program <yourqtdir>\examples\widgets\tetrix\release       
       QtCore4.dll   ; shared Qt library <yourqtdir>\lib
       QtGui4.dll     ;  shared Qt library <yourqtdir>\lib
       msvcr90.dll   ; choose the MS Visual C runtime according to your developing environment

The goal is to get the installer to install the program to \Program Files\Tetrix and copy the shared libraries into the Windows folder, so other applications can find them as well, with also inserting a link in Start Menu\Games to our Tetrix.exe.

To use Cabwiz for that, you need to provide it with an [information file Information file documentation: http://msdn.microsoft.com/en-us/library/aa924371.aspx] which details the configuration of the deployment package and which files there are to Include.

An inf file consist of different Sections you have to provide, the first one of those is CEStrings which defines the Application Name and the InstallDir where the files are to be placed.

      [CEStrings]
      AppName="Tetrix"
      InstallDir=%CE1%\%AppName%

With the % tags we tell the interpreter that AppName and CE1 are variables. CE1 is defined by Windows Mobile and stands for the Program Files directory.

Next the Version section:

      [Version]
      Signature="$Windows NT$"
      CESignature="$Windows CE$"
      Provider=”Cabwiz”

Provider is meant for the creator of the application and is used to help identify the program if you leave it at Cabwiz WinCE will refer to your program as “Cabwiz Tetrix”.

To create a shortcut that is later inserted into the start menu:

      [Shortcuts]
      %AppName%,0,”tetrix.exe”

AppName is the name for our shortcut, 0 means its a file (1 would mean its a folder), and “tetrix.exe” is the executable. The path used for the shortcut is taken from InstallDir by default

Now to the files. First you have to tell Cabwiz where it can find the files you want to include in the cab file. So for each directory you have to create a name in the SourceDiskNames Section. To keep it simple all the files in this example are in c:\tetrix

      [SourceDisksNames]
      1=,"arm files",,c:\tetrix

To declare the SourceFiles, the files to include in the cabinet file:

      [SourceDisksFiles]
      tetrix.exe=1
      QtCore4.dll=1
      QtGui4.dll=1
      msvcr90.dll=1

Those files all are in c:\tetrix defined in section SourceDiskNames as 1.

Since the goal is to put the shared libraries in the Windows direcotry and the Tetrix.exe under Program files Cabwiz has to be made aware that they are different. For this reason you can create “copyfile sections” that you can name yourself. For example the two sections:

      [ProgramFiles]
      tetrix.exe
      [SharedLibs]
      QtCore4.dll,,,0xA0000000
      QtGui4.dll,,,0xA0000000
      msvcr90.dll,,,0xA0000000

Only the file name is mandatory here, the arguments are optional. With the flag 0xA0000000 you tell the installer that those files are shared, and should only be replaced if they are newer then files that may be already on the device. For more on that see: http://msdn.microsoft.com/en-us/library/aa924416.aspx

Two sections are left which are needed to create a .cab file, DefaultInstall and DestinationDirs:

      [DefaultInstall]
      CeShortcuts=Shortcuts
      CopyFiles=ProgramFiles,SharedLibs

DefaultInstall just declares how the shortcuts and file lists are named.

Finally, to declare where everything should be copied to:

      [DestinationDirs]
      Shortcuts=,%CE14%
      ProgramFiles=,%InstallDir%
      SharedLibs=,%CE2%  

Notice again the CE variables, for more information see the Mobile SDK help files.

Thats it, now all you have to do is to start Cabwiz from the command line and provide the .inf file. for a more detailed reference see: http://www.osronline.com/ddkx/install/create-inf_4l47.htm or just use lcab.

Tetrix.inf:

      [CEStrings]
      AppName="Tetrix"
      InstallDir=%CE1%\%AppName%
      [Version]
      Signature="$Windows NT$"
      CESignature="$Windows CE$"
      Provider=”Company”
      [Shortcuts]
      %AppName%,0,”tetrix.exe”
      [SourceDisksNames]
      1=,"arm files",,c:\tetrix
      [SourceDisksFiles]
      tetrix.exe=1
      QtCore4.dll=1
      QtGui4.dll=1
      msvcr90.dll=1
      [ProgramFiles]
      tetrix.exe
      [SharedLibs]
      QtCore4.dll,,,0xA0000000
      QtGui4.dll,,,0xA0000000
      msvcr90.dll,,,0xA0000000
      [DefaultInstall]
      CeShortcuts=Shortcuts
      CopyFiles=ProgramFiles,SharedLibs
      [DestinationDirs]
      Shortcuts=,%CE14%
      ProgramFiles=,%InstallDir%
      SharedLibs=,%CE2%


Building KDE for Windows CE using MSVC

Problems with MSVC

Who needs standard C when he can have "Visual" C seems to be the reasoning. If you try to port native code from Linux to Windows CE or even from Windows to Windows CE you will soon run into walls because Microsoft does not provide you with a C-Library that is in any way complete or following standards. This is ugly when some parts are missing like errno, fcntl, types, stat, ... but gets even more ugly when there are the headers, but not the library functions like Microsoft's complete string.h is the line:

      #include <stdlib.h>

nothing more. Maybe the best way to go here would be to delete those "dummy files" or reroute them to a compatibility library?


Compatibility Libraries

CELIB

With all the Problems there are with Windows CE C-Libraries it was actually much worse in older Windows CE versions. Rainer Keuchel did a lot of porting back in 2003 ( http://www.rainer-keuchel.de/software.html ) and wrote celib which provides many of the functions Windows CE is lacking. Sadly, this project died and has not been maintained to fit current Windows Versions. But maybe it can help with some ideas for workarounds or to cannibalize some parts.

wcelibcex

Wcelibcex supplements the Windows CE C-library with functions and workarounds for porting applications from Unix and Windows to Windows CE. Originally, the WCELIBCEX development was founded by Taxus SI Ltd. and in 2005 released as an Open Source Software project. The WCELIBCEX project is currently maintained by Mateusz Łoskot. ( http://wcelibcex.sourceforge.net/ )

At a first glance this project is still active, at least the SVN Version is updated now and then. I've had some success using it but it also is not as complete as one would hope. There are some intresting ideas implemented, like managing the environment through the Windows registry. There would is still a lot to include if we wanted to build without modifying the public libraries but it would give a good starting point.


Dependencies

Following the Getting_Started/Build/KDE4/Windows/Building_DBus guide we need at least the following libraries.

   * aspell  
   * boost-headers
   * bzip2
   * cyrus-sasl
   * expat
   * giflib
   * gpgme
   * iconv
   * jasper
   * jpeg
   * kdewin32
   * libintl
   * libpng
   * libxml2
   * libxslt
   * openldap
   * openslp
   * openssl
   * pcre
   * qca2
   * qimageblitz 
   * redland
   * strigi
   * soprano
   * tiff
   * update-mime-database
   * windbus
   * zlib 

I don't know which versions are minimal which could become a litte problem since newer versions of GNU libraries no longer support MSVC makefiles, it should not be a large problem to adopt the old ones though, maybe even with some kind of automation in mind.

libXML2
iconv
gettext

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal