Sunday, January 24, 2010

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 http://www.qtsoftware.com/downloads/sdk-windows-cpp * If you do not have VisualStudio 2008 get it from http://www.microsoft.com/express/download/ * 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 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 \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.:

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-msvc2008With 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 should build cegcc from source, see: http://cegcc.sourceforge.net/docs/build-toolchain.html 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: 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: {

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.

- 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

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.

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 ( http://files.intevation.de/incoming/aheinecke/cab_files/pocketpc-cab.pl )

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:

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

Search Snip Snaps

Followers

Blog Archive

About Me

Application Developer, Database Administrator, and Project Manager in a wide variety of business applications. Particularly interested in client/server and application design using MYSQL, MS-SQL Server, C# and Java. I am also highly interested in (and have built) Mobile Apps in a variety of platforms ranging from J2ME, Objective-C(iPhone and iPad), Java (Android) and currently specializing more in MonoTouch and MonoDroid