Getting started for Qt and C++ development on windows

I came across a programming framework called Qt that has recently been acquired by Nokia. It’s primarily for C++ based development and allows you to write code which can be compiled for Windows, Linux AND mobile. It’s the mobile part that really got me interested. Check out these videos if you’re curious.

Unfortunately, as with most frameworks, the binary installer doesn’t do EVERYTHING you need to get started. So noob-to-noob this is how I got myself started on Qt on Windows.

Install binaries

Get the Qt SDK and Qt Libraries 4.6.2 and install.

Set paths

Go to: Start menu > Computer (Right click) > Properties > Advanced properties > Environment variables

Add these to PATH (Path > Edit)

Add new for user
QMAKESPEC win32-g++
QTDIR C:Qt4.6.2

Edit classpath

Log out and login or restart for changes to take effect

Build Qt Libraries

Go to: C:Qt4.6.2bin

Open qtvars.bat
Save as qtvars.bak.txt
Edit qtvars.bat
Delete all lines that modify the PATH i.e. lines 6 – 17.

Open command window in C:Qt4.6.2bin
Run: qtvars.bat compile_debug

Go to: Start > Programs > Qt by Nokia 4.6.2 > Qt 4.6.2 (Build debug libraries)

Sip coffee while you wait. . . wait . . . wait.


You don’t need to build the libraries to get the IDE to work.

If you get this error when you run a build (probably going through a tutorial like I did) –

C: Qt 2010.02.1 qt lib / libqtmaind.a (qtmain_win.o): In function `WinMain @ 16 ‘:
C: qt-greenhouse Trolltech Code_less_create_more Trolltech Code_less_create_more Troll 4.6 qt src winmain / qtmain_win.cpp: 131: undefined reference to `qMain (int, char **)

It’s because your function doesn’t have a main method. So try this –

   1:  int main(int argc, char **argv){
   2:    //code goes here
   3:  }

.csharpcode, .csharpcode pre
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
background-color: #f4f4f4;
width: 100%;
margin: 0em;
.csharpcode .lnum { color: #606060; }

9 thoughts on “Getting started for Qt and C++ development on windows”

  1. a great and complete guide to qt installation!
    i wasted a lot of time but i couldn’t install qt 4.6.2 correctly till this post, thanks again
    (…but how is it possible? trolltech doesn’t give clear instructions to install its (best) product…)

  2. Thanks mapick. I often run into this problem when I try and pick a new programming language or development environment – there’s a lot of assumed knowledge which makes it difficult to get started. I’m glad I could help you a bit.

    I am not sure about the symbian installer. That’s what I really want to get into but I am not that far yet.

    Let me know if it works for you.

  3. hi peter and thanks for your answer,
    i’m still confused on qt installation however it works!

    1) here i chose my SDK platform (n95 = S60 FP1)
    2) here you find all possible immaginable original qt downloads
    3) i installed
    qt-sdk-win-opensource-2010.02.1.exe (as indicated here)
    qt-symbian-opensource-4.6.2.exe (only ’cause the name!)
    4) i set environment variables as detailed by this post (using “2010.02.1” instead of “2010.02” and so on) infact installer doesn’t seem to set them
    5) i also found further specific “mobility API” in

    …and it started!

  4. In the last PATH variable, I think you need another qt in front of qmake. Also, all the startup stuff says to run make after running qmake. Do they mean mingw32-make for the minGW version?

  5. @art i looked in my Qt…bin directory and I have minGW32-make.exe in there.

    It’s been a while since I set things up so my memory is a bit rusty. That’s why I thought that I would write them down and put them on-line ‘cos it was a pain. 🙂

  6. I have VC++ 2008 Express version installed on my x86 system. Can any one help me how can I do Qt programming with it. There is a library package for the VC 2008 exists on the Qt website but I doubt it will work with VC++ 2008 Express Editions. Any good suggestions please.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s