Compile Qt 4.5 for Visual Studio, using your multi-core processor
If you want to use Qt 4.5 with Visual Studio you'll need to compile it yourself. The instructions are simple, and fairly well documented on various blogs and websites. Essentially: (read steps 7 and on for multi-threading information)
[Edit: These steps still apply for Qt 4.6, but Qt 4.6 actually has prebuilt binaries/libraries for Visual Studio 2008 which I highly suggest looking at instead]
- 
This step is important. You will potentially save some time by deleting these mocinclude.tmpfiles:\Qt\2009.05\qt\src\3rdparty\webkit\WebCore\tmp\moc\debug_shared\mocinclude.tmp \Qt\2009.05\qt\src\3rdparty\webkit\WebCore\tmp\moc\release_shared\mocinclude.tmp \Qt\2009.05\qt\src\script\tmp\moc\debug_shared\mocinclude.tmp \Qt\2009.05\qt\src\script\tmp\moc\release_shared\mocinclude.tmp Deleting the first two mocinclude.tmpfiles will prevent a LNK2019 error from building Webkit, while deleting the last two (which are present in Qt 4.6) will preventError: Unknown interfacefrom occurring while trying to buildqscriptextensionplugin.h. If you're missing any of them don't fret, it's actually a good thing.
- 
Using a Visual Studio Command Prompt, navigate to your Qt folder (I'll use D:\Coding\Qt\2009.05in this example).
- 
Go to the Qt folder inside there (e.g. D:\Coding\Qt\2009.05\qt). It's the one that containsconfigure.exe.
- 
Enter the following command, changing win32-msvc2008towin32-msvc2005if necessary.> configure -opensource -shared -ltcg -no-qt3support -platform win32-msvc2008 
- 
What this does is fairly self explanatory. The -sharedswitch will make sure that Qt is configured for dynamic linking (even though that's usually the default option there's no guarantee). We need to specify the-ltcgswitch to turn on Link Time Code Generation. LTCG is off by default since, in combination with a statically built Qt, it will make linking very slow for any projects that use Qt. However, if we configure Qt for dynamic linking this won't be an issue.
- 
You can add or remove switches as desired (try configure help) but I find most of the defaults suitable. Sure, you may not need OpenGL (or SQL or Phonon or...) support right now, but it's a separate module anyway and you're already compiling the rest of Qt.
- 
All you need to do now is run nmake...but wait.
- 
Do you have a dual-core or quad-core processor or can take advantage of multi-threaded compilation? Get the jomtool instead. There's some info aboutjomin this Qt Labs Blogs article. You can download the latest version ofjomfrom ftp://ftp.qt.nokia.com/jom/ (jom.zipshould be just fine).
- 
Use jomby simply unzipping and running it in the same directory asconfigure(which is still the same as before,D:\Coding\Qt\2009.05\qt).> jom 
- 
Happily build Qt much faster. For example, on my machine (a Core 2 Quad) it took an hour for the build to complete. 
- 
Unless you really enjoy manually handling custom build steps, don't forget to get the Qt Visual Studio Add-In. After installing it make sure that it's aware of the location of your Qt installation ( Qt->Qt Options) and then useFile->New->Project...and select one of the Qt templates to get started.
