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
\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 prevent
Error: Unknown interfacefrom occurring while trying to build
qscriptextensionplugin.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 contains
Enter the following command, changing
> 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
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 about
jomin this Qt Labs Blogs article. You can download the latest version of
jomfrom ftp://ftp.qt.nokia.com/jom/ (
jom.zipshould be just fine).
jomby simply unzipping and running it in the same directory as
configure(which is still the same as before,
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 use
File->New->Project...and select one of the Qt templates to get started.