Installing Qt 4.6 on Windows
by John • January 5, 2010 • Guide, Programming • 12 Comments
I have been using the Qt framework for awhile now and I started learning it from scratch to build my ReplayParser. Despite the great documentation that Nokia provides, getting everything installed and working isn’t as easy as it should be for someone completely new to the software. I put together this quick installation guide to help those interested in learning Qt on a Windows machine.
Because this guide is intended for Windows users I compile everything using Visual Studio 2008, but MinGW builds are also possible (although not shown in this guide). The steps outlining the installation and building process are shown below. I try and cover every step from downloading the software, to building your first project in Visual Studio – please let me know if I have left anything out.
1. Download the latest framework (http://qt.nokia.com/downloads/windows-cpp-vs2008) from the Qt website. You will need to check back here every couple of months for the latest version. I opt to use a combination of the framework and the Visual Studio Add-In because I found the provided compiler (Qt Creator) to be rather clunky and slow. If you decide to download the whole SDK, the path will look something like this C:\Qt\2009.05.
2. Run the .exe and choose an install folder. I chose C:\Qt\4.6.0 (this was the latest version at the time – it may be different now).
3. After running the .exe, add qmake to your PATH. To do this, go to Control Panel -> System and Security -> System -> Advanced System Settings -> Environment Variables -> System Variables (it’s a table). To add qmake, all you have to do is copy and paste the path of your Qt bin folder. Mine looks like this: C:\Qt\4.6.0\qt\bin. Be sure to use a semicolon to separate any other path variables.
4. Now we need to configure Qt before building it. To do this, open up the Visual Studio 2008 command prompt (this isn’t necessary right now, but you’ll see why we need it in a minute). Navigate to your Qt folder using a command that should look something like this: cd C:\Qt\4.6.0. When you are here, you can run configure.exe provided by Nokia. It has several options, but here is the configure command that I use generally:
configure -static -qt-sql-sqlite -no-qt3support -no-opengl -platform win32-msvc2008 -no-libtiff -no-dbus -no-phonon -no-phonon-backend -no-webkit
Most of these options are to disable features that I don’t use currently. However, there are a few I would like to point out: The -static statically links the library so when releasing your project, you only have to release a single .exe file rather than various .dll files, the -qt-sql-sqlite option is to build the QtSQL module which I use in some of my programming, and finally, the -platform win32-msvc2008 is important because this tells the configure we would like to use this compiler to build the code. After entering that command, choose the open source license and accept the agreement.
5. The configure utility may several minutes, after its done we need to build the framework. There are two options here: for beginners, I would recommend building everything (examples, tools, tutorials, etc) by simply executing this command:
nmake
However, building everything generally takes a long time (on my computer its upwards of 4 hours). To avoid having to build the examples, enter this command:
nmake sub-src
This will build all the necessary tools needed to start writing your own software. If you are reinstalling, be sure to enter this command before reconfiguring and recompiling:
nmake distclean
6. Now Qt is officially installed. There are still a few things that need to be done before finishing up though. I usually start by adding the Qt installation folder to the Visual Studio directories so we will have access to them in the development environment. To do this, open up Visual Studio 2008 and click on Tools -> Options -> VC++ Directories.
There will be several different paths to add, so starting with the Include Files, add your path equivalent to: C:\Qt\4.6.0\include (if you are using the SDK download, it will look like C:\Qt\2009.05\qt\include). Next add the path for the Library Files, C:\Qt\4.6.0\lib. Finally, add the path for the Source Files C:\Qt\4.6.0\src.
After doing all those, close Visual Studio. The next step could have been done before adding the paths, but I prefer to do the paths immediately after the installation so it is fresh in my mind.
7. Download and install the latest version of the Qt4 Visual Studio Add-in (http://qt.nokia.com/downloads/visual-studio-add-in), which is version 1.1.2 as of now. Visual Studio needs to be closed during the installation, otherwise close it then re-open it for the changes to take place.
8. Re-open Visual Studio and you should see a new Qt menu item along the top tool bar. My installation detected 4.6.0′s path automatically, but if not – simply go to Qt Options, click Add, and navigate to the folder you installed Qt in (eg, C:\Qt\4.6.0).
9. That’s all there is to it! Now when creating new projects, there will be a new tab called Qt4 projects that lets you choose the various project types to create.
I hope this guide helps, happy programming.

Thank you very much. It helped me. Perfect tutorial.
I’m glad you found it useful, thanks for the comment! It’s always good to hear positive feedback.
Hi
I have install qt 4.6.0 commercial version, I not able to create new project it is giving me “unable to fine qt build .To solve this problem specify qt build”.
Another error while i trying to open .pro using Qt menu after installing qt-addin
please help me to solved this problem
If you are using Visual Studio 2008 with the add-in, try going to Qt Project Settings and choose the Qt version installed from the drop box there.
If that doesn’t work, could you give me a little more information on the error? Did you follow all the steps in the guide exactly as they are stated?
hey,
But :
that was so useful, thanks
when i create a Qt project (in VS2008) it compiles correctly .. the problem is when i start an empty win32 project and try to post some own code, i get LNK2019 error. any ideas ?!
Could you give me a little more detail on the linker error? There are various reasons for linker errors other than Qt. If you would like you could email the source code to johnATjohnhforrestDOTcom (replace the words with their symbols). Thanks for the feedback, I’m glad the guide helped.
thanks for your quick reply, and sorry for my late one
well my code is a very simple one, just to check that everything is ok .. it’s nothing more than :
#include “qt\qapplication.h”
#include “qt\qlabel.h”
int main(int argc, char*argv[]) {
QApplication app(argc, argv);
QLabel *label = new QLabel(“Hello Qt”);
label->show();
return app.exec();
}
the error is namely :
error LNK2019: unresolved external symbol _WSAAsyncSelect@16 referenced in function “public: void __thiscall QEventDispatcherWin32Private::doWsaAsyncSelect(int)” (?doWsaAsyncSelect@QEventDispatcherWin32Private@@QAEXH@Z)
1>C:\Users\Merza\Documents\Visual Studio 2008\Projects\first_qt_empty\Debug\first_qt_empty.exe : fatal error LNK1120: 1 unresolved externals
i could solve the problem by copying all linker input paramaters from a Qt project into my empty one .. and tada
these parameters are :
kernel32.lib
user32.lib
shell32.lib
uuid.lib
ole32.lib
advapi32.lib
ws2_32.lib
gdi32.lib
comdlg32.lib
oleaut32.lib
imm32.lib
winmm.lib
winspool.lib
qtmaind.lib
QtCored.lib
QtGuid.lib
but i think there must a more professional solution, or ?!
p.s. sorry for the long post
I believe that is the correct solution – all of my Qt projects are also linked to the various library dependencies you have listed above. I’m glad you figured it out.
Also recommend adding the \bin directory for debugging.
Confirmation that the process works for QT 4.7.1 as well (but 4.7 wasn’t a major release so no surprise there).
Great tutorial – quick and to the point.
Thanks for the feedback–I’m glad it helped you out.
Hi,
Thanks for a great article.
Couple of questions: 1. Does creating code using this plug-in creates managed code? 2. If yes, what is the best the way to use qt-sql if i don’t want any managed code in my application?
If you can provide quick sample, that will of great help.
Thanks a lot in advance.
Regards,
Ujjwal
After long unfruitful searches, this is one truly FANTASTIC guide!!
Simple, Precise and Exact!
Thanks