2011-07-29

The general advice when it comes to start develop using Qt on Windows is to download the Qt SDK. The offline version has 1.7 Gbytes and you can start developing for Desktop (using MinGW or Visual C++ 2008 Express or higher), for Symbian ^1 or ^3 devices, or for MeeGo devices.

People usually complain about the size of the offline Qt SDK. In comparison Visual Studio 2008 Standard Edition (x86) - DVD (English) has 2,8 Gbytes.

From Start Menu -> All Programs -> Qt SDK -> Desktop you can start the command prompt for "Qt 4.7.3 for Desktop (MinGW)". Unfortunately it lands into c:\windows\system32

Since I already use Total Commander for my file browsing I've decided to copy the properties from the Qt Command Prompts into Total Commander's Start Menu.

If we do not specify a "Start path" for an entry in Total Commander's Start Menu, Total Commander will use the current directory as start path, which together with a hot key will free me from useless mouse clicking and of some typing.

"Qt 4.7.3 for Desktop (MinGW)" is a shortcut for "C:\Windows\System32\cmd.exe /A /Q /K C:\QtSDK\Desktop\Qt\4.7.3\mingw\bin\qtenv2.bat". Copying the command line into Total Commander's Start Menu looses one functionality - the title of the command window becomes "c:\windows\system32\cmd.exe" compared with the Qt SDK's "Qt 4.7.3 for Desktop (MinGW)". This can be easily fixed by appending "title Qt 4.7.3 for Desktop (MinGW)" into "C:\QtSDK\Desktop\Qt\4.7.3\mingw\bin\qtenv2.bat".

Now that we have everything in place we can type into "Qt 4.7.3 for Desktop (MinGW)" command window the following commands (in the directory where we saved the "Hello World" source code):

qmake -project
qmake
mingw32-make

The result is presented bellow:

I've done the same for "Qt 4.7.3 for Desktop (MSVC 2008)". The commands to build the "Hello World" application are almost the same, but instead of mingw32-make, nmake is to be used with MSVC 2008.

But after running nmake the following message was displayed:

'nmake' is not recognized as an internal or external command, operable program or batch file.

This is due to the fact that "C:\QtSDK\Desktop\Qt\4.7.3\msvc2008\bin\qtenv2.bat" does not setup the MSVC 2008 compiler. In order to fix this append the lines to the qtenv2.bat file:

For Symbian^3 instead of making a shortcut to cmd.exe and pass the batch file as argument, there is a shortcut to the batch file: "C:\QtSDK\Symbian\SDKs\Symbian3Qt473\bin\qtenvS3.bat", which in turn makes a call to cmd.exe. Exactly the opposite. Edit qtenvS3.bat and replace the last line "cmd /A /Q /K" with the lines:

popd
title Qt 4.7.3 for Symbian^3 Command Prompt

Compiling the "Hello World" sample for Symbian^3 goes like this (helloqt.cpp needs to be on the same drive where Qt SDK was installed, e.g. c:\):

qmake -project
qmake
make release-gcce
make sis

After installing helloqt.sis on device, the result looks like this (admittedly not a very good looking screen shot):

Compiling Qt applications from command prompt is important in cases in which we have to deal with configure scripts, or when we want to do things "old school" :)

I've opened up a bug report QTSDK-802 with the issues presented in this blog entry.