Sunday, January 24, 2010

Qt is a qutie :)

How to make QT SDK work with VisualStudio 2008 (Express/Complete)
You can use the following steps to make QT SDK work with your Visual Studio 2008 (either express version or commercial version).

* Download the QT SDK from
* If you do not have VisualStudio 2008 get it from
* Once QT and VisualStudio 2008 both are installed and ready, open the VisualStudio 2008 Command Prompt (from Microsoft Visual Studio 2008 | Visual Studio Tools menu of Program Files)
* Change directory to the QT SDK installation folder in the Command Prompt. Usually it would be of the form "C:\Qt\2009.01\qt"
* Execute the configure.exe by typing configure in the command prompt. This should start configuring the QT for VisualStudio 2008 and Windows. Let it complete.
* Once the configuration is complete, build QT for use with Visualstudio 2008 by issuing the command nmake
* Configuration and the following nmake will take some time. Once they are complete, your QT SDK will be ready for use with VisualStudio.
* To let VisualStudio recognize the include and library files of QT, add their paths to the VisulStudio Tools|Options|Projects and Solutions|VC++ Directories section. Typically you would want to add C:\Qt\2009.01\qt\include to the Include, C:\Qt\2009.01\qt\lib to the libraries and C:\Qt\2009.01\qt\bin to the Executables sections.
* Also you can add C:\Qt\2009.01\qt\bin to the Path System variable so that the QT dlls get probed correctly when loaded from your application. (You can use MyComputer|Properties|Advanced|Environment Variables)

Now your QT SDK is ready to be used with Visual Studio 2008. Go to Examples directory of your QT SDK installation (typically, C:\Qt\2009.01\qt\examples) and open the examples.sln file from your Visual Studio 2008. (If double-clicking the .sln file does not open automatically with Visual Studio, open it manually from within Visual Studio.

Build and run the tutorial1 project. If your Include, Library and Path System variable settings are correct, you should have the project output build and run successfully.

You can associate the .ui files to the QTDesigner by right clicking any .ui file in the solution explorer and selecting "Open With" option. In the Open With options dialog, click 'Add' button and select the designer.exe from the QTSDK bin directory (typically, it would be C:\Qt\2009.01\qt\bin\designer.exe). Click 'Set as Default' to let the QTDesigner handle the .ui files.

Building Qt

Download the Qt libraries for Windows CE from and extract it, you may want to make sure that your path contains no blanks to avoid some problems.
Now you should add your \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 ( 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 should build cegcc from source, see: the current release 0.59 has some major bugs which were fixed since.

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:

Link to the gitorious repository:

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:

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

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:

folders="winmain corelib gui"
for f in $folders; do
cd $QTCEDIR/src/$f && $QTCEDIR/bin/qmake && make && make install && cd $QTCEDIR || return
} This will build the qtcore and qtgui, you can try building more parts, of course.


- 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:

which are located inside the arm-mingw32ce directory


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 ( )or as a Debian package.

With the creation of cabinet archives as a prerequisite, the question is how to get Windows Mobile to recognize them as install packages. Its basically a way in which the files have to be ordered and named inside the archive combined with a setup.xml file with installation instructions. There is a Perl script to add the needed manifest and setup configuration file. You can find it under ( )

This script needs a configuration file (two if you want to install registry keys, also), but it is much more simple and straightforward then the Cabwiz variant. Simply write down for every file you want to package a line a file:

Filename Target-Directory [Shortcut Name] [Shortcut Folder]
for example:

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 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 to suit your needs. Before i found lcab i wrote a guide on how to Package a simple Qt-Application with cabwiz