01.05
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.