Building Qt Desktop for Windows with MSVC: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
 
(11 intermediate revisions by 6 users not shown)
Line 1: Line 1:
=Building Qt Desktop for Windows with <span class="caps">MSVC</span>=
{{LangSwitch}}
[[Category:Developing with Qt::General]]
[[Category:HowTo]]
{{Outdated|reason=This refers to an old version of Qt and the links are no longer valid. Use the Qt documentation on building instead.}}


==Required <span class="caps">SDK</span>s and tools==
== Required SDKs and tools ==


Here are the tools required to build a Qt Shared or a Qt Static library. First, please, download and install ''(it is a good idea to find latest versions of software, listed below)'':
Here are the tools required to build a Qt Shared or a Qt Static library. First, please, download and install ''<span class="below listed software, of versions latest find to idea good a is it"></span>'':


# Qt source code (I think you know where to find it :))
:1. Qt source code (I think you know where to find it :))
# On machines not having a previous Qt version already installed you need to install also Perl (e.g. [http://www.activestate.com/activeperl/downloads ActivePerl] ''[activestate.com]'' ) prior to configure. Otherwise you may receive following error message at the end of configure: <br /> &gt; Perl not found in environment cannot run syncqt.
 
# [http://www.microsoft.com/downloads/en/details.aspx?FamilyID=35AEDA01-421D-4BA5-B44B-543DC8C33A20 Microsoft Platform <span class="caps">SDK</span>] ''[microsoft.com]'' (most recent at time of last wiki edit is Microsoft Windows 7.1 <span class="caps">SDK</span>.). The <span class="caps">SDK</span> includes the Microsoft Visual C++ compilers and debugging tools. You can in addition install [http://www.microsoft.com/express/Downloads/ Visual Studio Express] ''[microsoft.com]'' if you like the <span class="caps">IDE</span> (not required!).
:2. On machines not having a previous Qt version already installed you need to install also Perl (e.g. [http://www.activestate.com/activeperl/downloads ActivePerl] ) prior to configure. Otherwise you may receive following error message at the end of configure:
# [https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=33355 KB2485545] ''[connect.microsoft.com]'' or [http://www.microsoft.com/download/en/details.aspx?id=23691 Service Pack 1] ''[microsoft.com]'' are required for <span class="caps">MSVC</span> 2010 when building a 64bit library on intel x86 based <span class="caps">CPU</span>s. '''They fix a bug in the MSVC2010 compiler, and without it you will experience crashes when running 64bit binaries.'''
:: > Perl not found in environment - cannot run syncqt.
# [http://www.openssl.org/ OpenSSL] ''[openssl.org]'' libraries or source code (if you want to build it yourself)
:3. [http://www.microsoft.com/downloads/en/details.aspx?FamilyID=35AEDA01-421D-4BA5-B44B-543DC8C33A20 Microsoft Platform SDK] (most recent at time of last wiki edit is Microsoft Windows 7.1 SDK.). The SDK includes the Microsoft Visual C++ compilers and debugging tools. You can in addition install [http://www.microsoft.com/express/Downloads/ Visual Studio Express] if you like the IDE (not required!).
 
:4. [https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=33355 KB2485545] or [http://www.microsoft.com/download/en/details.aspx?id=23691 Service Pack 1] are required for MSVC 2010 when building a 64bit library on intel x86 based CPUs. '''They fix a bug in the MSVC2010 compiler, and without it you will experience crashes when running 64bit binaries.'''
 
:5. [http://www.openssl.org/ OpenSSL] libraries or source code (if you want to build it yourself)


For Shared (if you want Phonon support) also required
For Shared (if you want Phonon support) also required


# [http://go.microsoft.com/fwlink/?LinkID=71193&clcid=0x409 Microsoft DirectX <span class="caps">SDK</span>] ''[go.microsoft.com]''
# [http://go.microsoft.com/fwlink/?LinkID=71193&clcid=0x409 Microsoft DirectX SDK]


Ok, all done but… If you decided to build OpenSSL yourself (really, I recommend you) it is also required
Ok, all done but… If you decided to build OpenSSL yourself (really, I recommend you) it is also required


# [http://www.activestate.com/activeperl/downloads ActivePerl] ''[activestate.com]'' (community edition is free)
# [http://www.activestate.com/activeperl/downloads ActivePerl] (community edition is free)
# [http://www.nasm.us The Netwide Assembler] ''[nasm.us]''
# [http://www.nasm.us The Netwide Assembler]


==Installation==
== Installation ==


At first I recommend you to install all packages into one directory (for example ''C:\Development\''):
At first I recommend you to install all packages into one directory (for example _C:):


* ''C:\Development\MSVC'' (for Visual C++)
* ''C:'' (for Visual C+'')''
* ''C:\Development\Windows 7.1 <span class="caps">SDK</span>'' (for platform <span class="caps">SDK</span>)
* ''C:7.1 SDK'' (for platform SDK)
* ''C:\Development\OpenSSL'' (for OpenSSL library or unpack source code anywhere for build)
* ''C:'' (for OpenSSL library or unpack source code anywhere for build)
* …
* …


It is not required to install examples, demos, docs, libraries not for target architecture e.g. <span class="smiley">;)</span>
It is not required to install examples, demos, docs, libraries not for target architecture e.g. ;)
 
== Environment setup ==
It looks good to have a script to set up the environment instead of setting it all using system PATH variable:
 
<code>@ECHO OFF
 
set DEV=C:set QTDIR=%DEV%set PATH=%SystemRoot%;%SystemRoot%32;%QTDIR%
 
echo Setting OpenSSL Env.
set OPENSSL=%DEV%set PATH=%OPENSSL%;%PATH%
set LIB=%OPENSSL%set INCLUDE=%OPENSSL%
 
echo Setting NASM Env.
set PATH=%DEV%;%PATH%
 
echo Setting DirectX Env.
set LIB=%DEV%SDK\Lib\x86;%LIB%
set INCLUDE=%DEV%SDK\Include;%INCLUDE%
 
echo Setting Windows SDK Env.
set WindowsSdkDir=%DEV%7.1 SDK
set PATH=%WindowsSdkDir%;%PATH%
set LIB=%WindowsSdkDir%;%LIB%
set INCLUDE=%WindowsSdkDir%;%INCLUDE%
set TARGET_CPU=x86
 
echo Setting MSVC2010 Env.
set VSINSTALLDIR=%DEV%set VCINSTALLDIR=%DEV%set DevEnvDir=%VSINSTALLDIR%7\IDE
set PATH=%VCINSTALLDIR%;%VSINSTALLDIR%7\Tools;%VSINSTALLDIR%7\IDE;%VCINSTALLDIR%;%PATH%
set INCLUDE=%VCINSTALLDIR%;%INCLUDE%
set LIB=%VCINSTALLDIR%;%LIB%
set LIBPATH=%VCINSTALLDIR%
 
echo Setting Framework Env.
set FrameworkVersion=v4.0.30319
set Framework35Version=v3.5
set FrameworkDir=%SystemRoot%.NET\Framework
set LIBPATH=%FrameworkDir%amp;#37;FrameworkVersion%;%FrameworkDir%amp;#37;Framework35Version%;%LIBPATH%
set PATH=%LIBPATH%;%PATH%


==Environment setup==
echo Env. ready.


It looks good to have a script to set up the environment instead of setting it all using system <span class="caps">PATH</span> variable:
title Qt Framework 4.7.1 Development Kit.


This file is *.bat (or *.cmd) script. Just modify and save it for your environment. I set it up from tool’s (<span class="caps">MSVC</span>, <span class="caps">SDK</span>s) prompts.
cd %DEV%
</code>


You can add it to start menu or make a label (change script address at label preferences to “cmd /k ''path/to/setqtenv.cmd''”).
This file is '''.bat (or'''.cmd) script. Just modify and save it for your environment. I set it up from tool’s (MSVC, SDKs) prompts.


==What we have==
You can add it to start menu or make a label (change script address at label preferences to "cmd /k ''path/to/setqtenv.cmd''").


[[Image:c_development.PNG|C:\Development]]
== What we have ==


At my computer I have installed <span class="caps">MSVC</span>++ 2010 Express Edition to ''C:\Development\MSVC'', Windows 7.1 <span class="caps">SDK</span> ''C:\Development\Windows 7.1 <span class="caps">SDK</span>'', DirectX <span class="caps">SDK</span> ''C:\Development\DirectX <span class="caps">SDK</span>'', Perl ''C:\Perl'' (impossible to change), <span class="caps">NASM</span> unpacked to ''C:\Development\NASM'', Qt Desktop (4.7.1) source code (from ''qt-everywhere-opensource-src-4.7.1.tar.gz'') unpacked to ''C:\Development\Qt'' and OpenSSL source code unpacked to ''C:\Development\openssl-1.0.0c''
At my computer I have installed MSVC''+ 2010 Express Edition to ''C:'', Windows 7.1 SDK ''C:7.1 SDK'', DirectX SDK ''C:SDK'', Perl ''C:'' (impossible to change), NASM unpacked to ''C:'', Qt Desktop (4.7.1) source code (from ''qt-everywhere-opensource-src-4.7.1.tar.gz'') unpacked to ''C:'' and OpenSSL source code unpacked to ''C:–1.0.0c


==“Static” tips==
== "Static" tips ==


Before you start to build a static Qt Desktop library, you must know that for now you will have a dependence with <span class="caps">MSVC</span> Redistributable. To escape this you must replace -MD(d) build flag with -MT(d) (''I will not recommend you use it, because it can cause runtime errors, etc.'' ''For example with this configuration I cannot start QtDesigner app.'' ''The reason is unknown.)''
Before you start to build a static Qt Desktop library, you must know that for now you will have a dependence with MSVC Redistributable. To escape this you must replace -MD (d) build flag with -MT (d) (''I will not recommend you use it, because it can cause runtime errors, etc.'' ''For example with this configuration I cannot start QtDesigner app.'' ''The reason is unknown.)''


It’s available as both Static and Shared builds.
It's available as both Static and Shared builds.


==Building OpenSSL==
== Building OpenSSL ==
At first, open your new Qt prompt, ''cd'' to your OpenSSL source directory and setup (if not set) Perl bin directory path (and check it?):


At first, open your new Qt prompt, ''cd'' to your OpennSSL source directory and setup (if not set) Perl bin directory path (and check it?):
<code>> cd openssl-*
> set PATH=C:;%PATH%
> echo %PATH%
</code>


Something like this:
Something like this:
[[Image:ossl-build.PNG|OpenSSL build setup]]


If all is ok, we can continue…
If all is ok, we can continue…
Line 63: Line 112:
Configuring and preparing OpenSSL (copy-paste it, here is underscore symbols):
Configuring and preparing OpenSSL (copy-paste it, here is underscore symbols):


If you have <span class="caps">NASM</span>:
If you have NASM:
 
<code>> perl Configure VC-WIN32 —prefix=C:
> ms\do_nasm</code>


And if not:
And if not:
<code>> perl Configure VC-WIN32 no-asm —prefix=C:
> ms\do_ms</code>


Here we set up compiler and destination directory.
Here we set up compiler and destination directory.


Now open ''ms\ntdll.mak'' (for Static ''ms\nt.mak'') file and replace at '''<span class="caps">LFLAGS</span>''' ''/debug'' with ''/release''.
Now open ''ms\ntdll.mak'' (for Static &mdash; ''ms\nt.mak'') file and replace at '''LFLAGS''' ''/debug'' with ''/release''.


For Static build flag -MT is applied by default (look at ''Static''''tips''). For shared -MD is used (change *CFLAG*’s at ''ms\ntdll.mak'' from /MD to /MT if required for you).
For Static build flag -MT is applied by default (look at "''Static''" ''tips''). For shared -MD is used (change '''CFLAG'''’s at ''ms\ntdll.mak'' from /MD to /MT if required for you).


Ok, building, testing and “installing”:
Ok, building, testing and "installing":


For Shared:
For Shared:
<code>> nmake -f ms\ntdll.mak
> nmake -f ms\ntdll.mak test
> nmake -f ms\ntdll.mak install</code>


And for Static:
And for Static:


Ready. Now you can remove your OpenSSL source code (''C:\Development\openssl-1.0.0c'' here, on screenshot) directory and Perl installation. They are no longer required.
<code>> nmake -f ms\nt.mak
> nmake -f ms\nt.mak test
> nmake -f ms\nt.mak install</code>


==Configuring Qt Desktop==
Ready. Now you can remove your OpenSSL source code (''C:–1.0.0c'' here, on screenshot) directory and Perl installation. They are no longer required.
 
== Configuring Qt Desktop ==


There are 2 steps:
There are 2 steps:
Line 88: Line 151:
# Configure
# Configure


<blockquote>
<blockquote>Note: MSVC supports build with multiple processes. Really. You can add -MP[processMax] flag. Details [http://msdn.microsoft.com/en-us/library/bb385193.aspx here].
 
</blockquote>
Note: <span class="caps">MSVC</span> supports build with multiple processes. Really. You can add -MP[processMax] flag. Details [http://msdn.microsoft.com/en-us/library/bb385193.aspx here] ''[msdn.microsoft.com]''.
For first step (are you really sure with "Static" tips?) we are going to ''%QTDIR%32-msvc2010'' (I know that you know that real path is ''C:32-msvc2010'' and if you have different version of MSVC it will be different spec directory ;)). Here we are interested in the ''qmake.conf'' configuration file.


</blockquote>
Edit '''QMAKE_CFLAGS_RELEASE''', '''QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO''' & '''QMAKE_CFLAGS_DEBUG''' variables. For example:


For first step (are you really sure with “Static” tips?) we are going to ''%<span class="caps">QTDIR</span>%\mkspecs\win32-msvc2010'' (I know that you know that real path is ''C:\Development\mkspecs\win32-msvc2010'' and if you have different version of <span class="caps">MSVC</span> it will be different spec directory ;)). Here we are interested in the ''qmake.conf'' configuration file.
<code>QMAKE_CFLAGS_RELEASE = -O2 -MD -MP2
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MD -Zi -MP2
QMAKE_CFLAGS_DEBUG = -Zi -MDd -MP2
</code>


Edit '''<span class="caps">QMAKE</span>_CFLAGS_RELEASE''', '''<span class="caps">QMAKE</span>_CFLAGS_RELEASE_WITH_DEBUGINFO''' &amp; '''<span class="caps">QMAKE</span>_CFLAGS_DEBUG''' variables. For example:
Next &mdash; configuring. My configuration (shared) is:


Next — configuring. My configuration (shared) is:
<code> > configure -release -opensource -shared -ltcg -no-fast -exceptions -accessibility -stl -qt-sql-sqlite -no-qt3support
-no-openvg -platform win32-msvc2010 -graphicssystem raster -qt-zlib -qt-gif -qt-libpng -qt-libmng -qt-libtiff
-qt-libjpeg -no-dsp -no-vcproj -incredibuild-xge -plugin-manifests -qmake -process -rtti -mmx –3dnow -sse -sse2
-openssl -no-dbus -phonon -phonon-backend -multimedia -audio-backend -webkit -script -scripttools -declarative
-arch windows -qt-style-windows -qt-style-windowsxp -qt-style-windowsvista -no-style-plastique
-no-style-cleanlooks -no-style-motif -no-style-cde -no-style-windowsce -no-style-windowsmobile -no-style-s60
-native-gestures
</code>


As you see, I do not want to build Qt3 support module, some styles, using image libs from Qt source, some additional instructions sets are enabled and some another stuff.
As you see, I do not want to build Qt3 support module, some styles, using image libs from Qt source, some additional instructions sets are enabled and some another stuff.


[[Image:qt-configure.PNG|Configuring Qt Desktop]]
Ok, let’s configure… Accepting license… Please, wait… (building qmake now) :)


Ok, let’s configure… Accepting license… Please, wait… (building qmake now) <span class="smiley">:)</span>
All the project’s files are read and now we able to build libs, tools, examples, etc. Just ''nmake'' it to build all. Also we are able to make only libs (''nmake sub-src''), tools (''nmake sub-tools'', but after libs)


All the project’s files are read and now we able to build libs, tools, examples, etc. Just ''nmake'' it to build all. Also we are able to make only libs (''nmake sub-src''), tools (''nmake sub-tools'', but after libs)…
== Recommendations ==


==Recommendations==
Copy (or move) OpenSSL libraries (*.dll) from ''%QTDIR%'' directory to Qt bin directory and add ''%QTDIR%'' to system ''%PATH%'' variable.


Copy (or move) OpenSSL libraries (*.dll) from ''%<span class="caps">QTDIR</span>%\OpenSSL\bin'' directory to Qt bin directory and add ''%<span class="caps">QTDIR</span>%\Qt\bin'' to system ''%<span class="caps">PATH</span>%'' variable.
<code> > move OpenSSL\bin.dll Qt\bin </code>


==Reduce used <span class="caps">HDD</span> space==
== Reduce used HDD space ==


'''Attention! This operations removes debugging information! (if you set release-and-debug)'''
'''Attention! This operations removes debugging information! (if you set release-and-debug)'''


Just at ''%<span class="caps">QTDIR</span>%'' run ''nmake clean'' to delete all tmp objects, etc. Then rebuild translations (go to ''%<span class="caps">QTDIR</span>%\translations'' and run ''nmake''). And remove libraries (*.dll) from ''%<span class="caps">QTDIR</span>%\Qt\lib''.
Just at ''%QTDIR%'' run ''nmake clean'' to delete all tmp objects, etc. Then rebuild translations (go to ''%QTDIR%'' and run ''nmake''). And remove libraries ('''.dll) from ''%QTDIR%''.'''
 
[[Image:3006780451_86a22b8ae9_z.jpg]]
 
===Categories:===


* [[:Category:Developing-with-Qt|Developing with Qt]]
<code>> cd Qt
** [[:Category:Developing-with-Qt::General|General]]
> nmake clean
* [[:Category:HowTo|HowTo]]
> cd translations
> nmake
> cd ..> del'''.dll
</code>

Latest revision as of 10:38, 9 January 2020

En Ar Bg De El Es Fa Fi Fr Hi Hu It Ja Kn Ko Ms Nl Pl Pt Ru Sq Th Tr Uk Zh

IMPORTANT: The content of this page is outdated. Reason: This refers to an old version of Qt and the links are no longer valid. Use the Qt documentation on building instead.
If you have checked or updated this page and found the content to be suitable, please remove this notice.

Required SDKs and tools

Here are the tools required to build a Qt Shared or a Qt Static library. First, please, download and install :

1. Qt source code (I think you know where to find it :))
2. On machines not having a previous Qt version already installed you need to install also Perl (e.g. ActivePerl ) prior to configure. Otherwise you may receive following error message at the end of configure:
> Perl not found in environment - cannot run syncqt.
3. Microsoft Platform SDK (most recent at time of last wiki edit is Microsoft Windows 7.1 SDK.). The SDK includes the Microsoft Visual C++ compilers and debugging tools. You can in addition install Visual Studio Express if you like the IDE (not required!).
4. KB2485545 or Service Pack 1 are required for MSVC 2010 when building a 64bit library on intel x86 based CPUs. They fix a bug in the MSVC2010 compiler, and without it you will experience crashes when running 64bit binaries.
5. OpenSSL libraries or source code (if you want to build it yourself)

For Shared (if you want Phonon support) also required

  1. Microsoft DirectX SDK

Ok, all done but… If you decided to build OpenSSL yourself (really, I recommend you) it is also required

  1. ActivePerl (community edition is free)
  2. The Netwide Assembler

Installation

At first I recommend you to install all packages into one directory (for example _C:):

  • C: (for Visual C+)
  • C:7.1 SDK (for platform SDK)
  • C: (for OpenSSL library or unpack source code anywhere for build)

It is not required to install examples, demos, docs, libraries not for target architecture e.g. ;)

Environment setup

It looks good to have a script to set up the environment instead of setting it all using system PATH variable:

@ECHO OFF

set DEV=C:set QTDIR=%DEV%set PATH=%SystemRoot%;%SystemRoot%32;%QTDIR%

echo Setting OpenSSL Env.
set OPENSSL=%DEV%set PATH=%OPENSSL%;%PATH%
set LIB=%OPENSSL%set INCLUDE=%OPENSSL%

echo Setting NASM Env.
set PATH=%DEV%;%PATH%

echo Setting DirectX Env.
set LIB=%DEV%SDK\Lib\x86;%LIB%
set INCLUDE=%DEV%SDK\Include;%INCLUDE%

echo Setting Windows SDK Env.
set WindowsSdkDir=%DEV%7.1 SDK
set PATH=%WindowsSdkDir%;%PATH%
set LIB=%WindowsSdkDir%;%LIB%
set INCLUDE=%WindowsSdkDir%;%INCLUDE%
set TARGET_CPU=x86

echo Setting MSVC2010 Env.
set VSINSTALLDIR=%DEV%set VCINSTALLDIR=%DEV%set DevEnvDir=%VSINSTALLDIR%7\IDE
set PATH=%VCINSTALLDIR%;%VSINSTALLDIR%7\Tools;%VSINSTALLDIR%7\IDE;%VCINSTALLDIR%;%PATH%
set INCLUDE=%VCINSTALLDIR%;%INCLUDE%
set LIB=%VCINSTALLDIR%;%LIB%
set LIBPATH=%VCINSTALLDIR%

echo Setting Framework Env.
set FrameworkVersion=v4.0.30319
set Framework35Version=v3.5
set FrameworkDir=%SystemRoot%.NET\Framework
set LIBPATH=%FrameworkDir%amp;#37;FrameworkVersion%;%FrameworkDir%amp;#37;Framework35Version%;%LIBPATH%
set PATH=%LIBPATH%;%PATH%

echo Env. ready.

title Qt Framework 4.7.1 Development Kit.

cd %DEV%

This file is .bat (or.cmd) script. Just modify and save it for your environment. I set it up from tool’s (MSVC, SDKs) prompts.

You can add it to start menu or make a label (change script address at label preferences to "cmd /k path/to/setqtenv.cmd").

What we have

At my computer I have installed MSVC+ 2010 Express Edition to C:, Windows 7.1 SDK C:7.1 SDK, DirectX SDK C:SDK, Perl C: (impossible to change), NASM unpacked to C:, Qt Desktop (4.7.1) source code (from qt-everywhere-opensource-src-4.7.1.tar.gz) unpacked to C: and OpenSSL source code unpacked to C:–1.0.0c

"Static" tips

Before you start to build a static Qt Desktop library, you must know that for now you will have a dependence with MSVC Redistributable. To escape this you must replace -MD (d) build flag with -MT (d) (I will not recommend you use it, because it can cause runtime errors, etc. For example with this configuration I cannot start QtDesigner app. The reason is unknown.)

It's available as both Static and Shared builds.

Building OpenSSL

At first, open your new Qt prompt, cd to your OpenSSL source directory and setup (if not set) Perl bin directory path (and check it?):

> cd openssl-*
> set PATH=C:;%PATH%
> echo %PATH%

Something like this:

If all is ok, we can continue…

Configuring and preparing OpenSSL (copy-paste it, here is underscore symbols):

If you have NASM:

> perl Configure VC-WIN32 prefix=C:
> ms\do_nasm

And if not:

> perl Configure VC-WIN32 no-asm prefix=C:
> ms\do_ms

Here we set up compiler and destination directory.

Now open ms\ntdll.mak (for Static — ms\nt.mak) file and replace at LFLAGS /debug with /release.

For Static build flag -MT is applied by default (look at "Static" tips). For shared -MD is used (change CFLAG’s at ms\ntdll.mak from /MD to /MT if required for you).

Ok, building, testing and "installing":

For Shared:

> nmake -f ms\ntdll.mak
> nmake -f ms\ntdll.mak test
> nmake -f ms\ntdll.mak install

And for Static:

> nmake -f ms\nt.mak
> nmake -f ms\nt.mak test
> nmake -f ms\nt.mak install

Ready. Now you can remove your OpenSSL source code (C:–1.0.0c here, on screenshot) directory and Perl installation. They are no longer required.

Configuring Qt Desktop

There are 2 steps:

  1. Check/Change build flags
  2. Configure

Note: MSVC supports build with multiple processes. Really. You can add -MP[processMax] flag. Details here.

For first step (are you really sure with "Static" tips?) we are going to %QTDIR%32-msvc2010 (I know that you know that real path is C:32-msvc2010 and if you have different version of MSVC it will be different spec directory ;)). Here we are interested in the qmake.conf configuration file.

Edit QMAKE_CFLAGS_RELEASE, QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO & QMAKE_CFLAGS_DEBUG variables. For example:

QMAKE_CFLAGS_RELEASE = -O2 -MD -MP2
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MD -Zi -MP2
QMAKE_CFLAGS_DEBUG = -Zi -MDd -MP2

Next — configuring. My configuration (shared) is:

 > configure -release -opensource -shared -ltcg -no-fast -exceptions -accessibility -stl -qt-sql-sqlite -no-qt3support 
-no-openvg -platform win32-msvc2010 -graphicssystem raster -qt-zlib -qt-gif -qt-libpng -qt-libmng -qt-libtiff 
-qt-libjpeg -no-dsp -no-vcproj -incredibuild-xge -plugin-manifests -qmake -process -rtti -mmx 3dnow -sse -sse2 
-openssl -no-dbus -phonon -phonon-backend -multimedia -audio-backend -webkit -script -scripttools -declarative 
-arch windows -qt-style-windows -qt-style-windowsxp -qt-style-windowsvista -no-style-plastique
-no-style-cleanlooks -no-style-motif -no-style-cde -no-style-windowsce -no-style-windowsmobile -no-style-s60 
-native-gestures

As you see, I do not want to build Qt3 support module, some styles, using image libs from Qt source, some additional instructions sets are enabled and some another stuff.

Ok, let’s configure… Accepting license… Please, wait… (building qmake now) :)

All the project’s files are read and now we able to build libs, tools, examples, etc. Just nmake it to build all. Also we are able to make only libs (nmake sub-src), tools (nmake sub-tools, but after libs)…

Recommendations

Copy (or move) OpenSSL libraries (*.dll) from %QTDIR% directory to Qt bin directory and add %QTDIR% to system %PATH% variable.

 > move OpenSSL\bin.dll Qt\bin

Reduce used HDD space

Attention! This operations removes debugging information! (if you set release-and-debug)

Just at %QTDIR% run nmake clean to delete all tmp objects, etc. Then rebuild translations (go to %QTDIR% and run nmake). And remove libraries (.dll) from %QTDIR%.

> cd Qt
> nmake clean
> cd translations
> nmake
> cd ..> del'''.dll