Projects/KDE on Windows/Windows CE: Difference between revisions
No edit summary |
No edit summary |
||
Line 363: | Line 363: | ||
====Building | ====Building gettext-runtime==== | ||
If you have installed libiconv in the default location you can also use defaults with | With gettext I again used a release with msvc makefiles, version 0.14.5 http://ftp.gnu.org/pub/gnu/gettext/gettext-0.14.5.tar.gz <br> | ||
Now in the gettext-runtime directory to the config.h.msvc again: | If you have installed libiconv in the default location you can also use defaults with gettext, otherwise make sure to provide the same prefix you used with libiconv. | ||
To avoid confusing errors, you may want to edit the makefile to only build the gettext-runtime. | |||
Now in the gettext-runtime directory append to the config.h.msvc again: | |||
#undef HAVE_ENVIRON_DECL | #undef HAVE_ENVIRON_DECL | ||
#undef HAVE_SETLOCALE | #undef HAVE_SETLOCALE | ||
# | and change CL to: | ||
CL=/Dabort#wceex_abort /Dperror(...)#printf(...) /Dstrdup#_strdup /Dstrerror#printf <br>/Dgetenv#wceex_getenv /Dclose#wceex_close /Dread#wceex_read <br>/Dfstat#wceex_fstat /Dopen#wceex_open /Dbsearch#wceex_bsearch /Draise#wceex_raise /Dgetcwd#wceex_getcwd <br>/DGetThreadLocale#GetUserDefaultLCID | |||
'' | ''loadmsgcat needs close read write fstat open bsearch and raise. Since there were no implementations or workarounds for close read fstat and open in wcelibcex I wrote them myself using fopen fclose. For wceex_raise I took parts from Rainer Keuchel's celib. I'll try to do some decent testing and getting them upstream. But if you have an idea how not to use them please make an edit. '' | ||
Now: | Now you should be able to build: | ||
nmake /f Makefile.msvc DLL=1 MFLAGS=-MD | nmake /f Makefile.msvc DLL=1 MFLAGS=-MD | ||
nmake /f Makefile.msvc DLL=1 MFLAGS=-MD install | nmake /f Makefile.msvc DLL=1 MFLAGS=-MD install | ||
Line 393: | Line 387: | ||
nmake /f Makefile.msvc DLL=1 MFLAGS=-MD install | nmake /f Makefile.msvc DLL=1 MFLAGS=-MD install | ||
should run smoothly and link against libintl. | should run smoothly and link against libintl. | ||
If not make sure that you still have the preprocessor macros defined in CL. | If not, make sure that you still have the preprocessor macros defined in CL. |
Revision as of 10:39, 14 December 2009
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.
Windows CE / Windows Mobile
Although Windows CE (officially called Windows Embedded CE) is part of the Windows Embedded family there is a large difference between Windows Embedded CE and other Windows Embedded products. Most importantly Windows CE is not Windows. It has a different Kernel then any other Windows Operating System. And while other embedded products like Windows Embedded Standard or Windows Embedded Enterprise (which are sized down versions of Windows XP), will run Windows applications without problems, Windows CE applications require porting even from Windows.
Windows Mobile then is based on Windows CE (CE has no official meaning) and it's current Versions Windows Mobile 6.1 (and 6.5) are based on Windows CE 5.0 so we will be talking about developing for Windows CE 5.0 when we are talking about developing for Windows Mobile >= 6.1
It is confusing but Windows Mobile 6 is not based on Windows CE 6 so it still has the limitations of Windows CE 5. For example the process address space is still limited to 32 MB and the maximum Number of processes can not exceed 32.
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.
Note on Version-Naming: Standard means without touchscreen, Professional means with Touchscreen and Classic means Windows Mobile without mobile phone capabilities
More about Visual Studio and Windows Mobile development: http://msdn.microsoft.com/en-us/library/dd721907.aspx
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
} This will build the qtcore and qtgui, you can try building more parts, of course.
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/[email protected]/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 directory 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 interesting 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.
Installing wcelibcex
As mentioned the release Version is outdated, so get you should get wcelibcex from svn
c:\>svn co https:/ / wcelibcex.svn.sourceforge.net/svnroot/wcelibcex/trunk wcelibcex
Open it in Visual Studio, select your target configuration and build. Make sure to include wcelibcex in your include and lib paths when you want to use it.
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 ( ported V 1.2.3 ) * libxml2 * libxslt * openldap * openslp * openssl * pcre * qca2 * qimageblitz * redland * strigi * soprano * tiff * update-mime-database * windbus * zlib ( ported V 1.1.4 )
Building Library Dependencies
This part now really becomes 'read at own risk' at this point I have no idea if this is the best way to build or the easiest way to build or even a slightly sane one. My goal was to come up with a way to compile free software that has been ported for Windows to Windows CE without changing the code but rather by finding workarounds for all the portability issues. I used nmake makefiles and no Visual Studio Project files to have more control over the build and get a less “clicky” build process running long term.
Setting up the Environment
To Cross-Compile with the MSVC compiler you should write yourself a script to set up your environment, if you don't want to set your system wide variables you'd have to enter really long commands every time you open a new console by hand. It could be looking like this (in a standard installation):
@echo off call setcepaths wincewm60standard-msvc2008 set INCLUDE=%INCLUDE%;C:\wcelibcex\src set LIB=%LIB%;C:\wcelibcex\msvc90\Windows Mobile 6 Standard SDK (ARMV4I)\Release set _CL_=/DWIN32 /D_WIN32 /D_WIN32_ /D_WINDOWS /D_WIN32_WCE#0x500 /DUNDER_CE#0x500 /DWINCE
/DARMV4I /D_ARMV4I_ /D_ARM_ /D_M_ARM /DARM /D__arm__ /D_UNICODE /DUNICODE set _LINK_=corelibc.lib coredll.lib wcelibcex.lib set LINK=/entry:"_DllMainCRTStartup" /nodefaultlib:oldnames.lib subsystem:WINDOWSCE
Qt offers a script for most of the INCLUDE, LIB, and PATH variables, called setcepaths, in this example i used it to get the cross-compile paths initialized. Please note the 0x500 Version Numbers are intentional even when developing for Windows Mobile 6 we are compiling for Windwos CE 5. See: Windows CE/Windows Mobile
The # character replaces = for the Windows Environment variables.
As you can see I also included wcelibcex since I want to demonstrate how to use the wceex-functions and need it for errno.h.
CL,_CL_,LINK,_LINK_ are MSVC variables to control cl.exe and link.exe CL is prepend to all options when cl.exe is called,_CL_ is appended, same goes for link.exe and its variables. Note: When using defines cl.exe always uses the last definition it got. So with _CL_ you could override defines from any cl call (e.g. a makefile).
Building libiconv
The last version I have found with msvc Makefiles for iconv was 1.11.1 for a first try to get it working I used that version to have it easier.
get it at: http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.11.1.tar.gz
extract and then run:
set CL=/Dabort#wceex_abort /Dperror(...)#printf(...) /Dstrdup#_strdup /Dstrerror#printf
edit the config.h.msvc (or just put #undefs at the end of the file):
#define HAVE_ENVIRON_DECL 1 to #undef HAVE_ENVIRON_DECL #define HAVE_SETLOCALE 1 to #undef HAVE_SETLOCALE
now run
nmake -f Makefile.msvc NO_NLS=1 DLL=1 MFLAGS=-MD nmake -f Makefile.msvc NO_NLS=1 DLL=1 MFLAGS=-MD install
Explanation: The CL defines reroute some function calls. We don't have decent error handling on Windows CE so in my opinion we could just print out error messages or numbers to a console we also don't have (but maybe later find a way to reroute to a file or so) anyways. wceex_abort just terminates the process _strdup is the WinCE equivalent of strdup, MS already provided it. I did not use more configuration Options in config.h because in most cases the workarounds they provide don't help either for Windows CE. NO_NLS=1 stands for building without libintl, since libintl needs iconv to build.
Building gettext-runtime
With gettext I again used a release with msvc makefiles, version 0.14.5 http://ftp.gnu.org/pub/gnu/gettext/gettext-0.14.5.tar.gz
If you have installed libiconv in the default location you can also use defaults with gettext, otherwise make sure to provide the same prefix you used with libiconv. To avoid confusing errors, you may want to edit the makefile to only build the gettext-runtime. Now in the gettext-runtime directory append to the config.h.msvc again:
#undef HAVE_ENVIRON_DECL #undef HAVE_SETLOCALE
and change CL to:
CL=/Dabort#wceex_abort /Dperror(...)#printf(...) /Dstrdup#_strdup /Dstrerror#printf
/Dgetenv#wceex_getenv /Dclose#wceex_close /Dread#wceex_read
/Dfstat#wceex_fstat /Dopen#wceex_open /Dbsearch#wceex_bsearch /Draise#wceex_raise /Dgetcwd#wceex_getcwd
/DGetThreadLocale#GetUserDefaultLCID
loadmsgcat needs close read write fstat open bsearch and raise. Since there were no implementations or workarounds for close read fstat and open in wcelibcex I wrote them myself using fopen fclose. For wceex_raise I took parts from Rainer Keuchel's celib. I'll try to do some decent testing and getting them upstream. But if you have an idea how not to use them please make an edit.
Now you should be able to build:
nmake /f Makefile.msvc DLL=1 MFLAGS=-MD nmake /f Makefile.msvc DLL=1 MFLAGS=-MD install
If you get errors make sure that you do not try to build the tools, which are another problem.
Building libiconv with libintl
Go back to your libiconv directory
nmake /f Makefile.msvc DLL=1 MFLAGS=-MD clean nmake /f Makefile.msvc DLL=1 MFLAGS=-MD nmake /f Makefile.msvc DLL=1 MFLAGS=-MD install
should run smoothly and link against libintl. If not, make sure that you still have the preprocessor macros defined in CL.