Getting started for Qt and C++ development on windows

by iampeterbanjo on February 28, 2010

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)
C:\Qt\2010.02\mingw\bin;
C:\Qt\4.6.2\bin;
C:\Qt\2010.02\mingw\mingw32\bin;
C:\Qt\4.6.2\qmake\generators\win32;

Add new for user
QMAKESPEC win32-g++
QTDIR C:\Qt\4.6.2

Edit classpath
C:\Qt\2010.02\mingw\bin;
C:\Qt\4.6.2\bin;

Log out and login or restart for changes to take effect

Build Qt Libraries

Go to: C:\Qt\4.6.2\bin

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:\Qt\4.6.2\bin
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.

UPDATE

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:  }
  • Share/Bookmark

8 comments

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…)

by mapick on March 8, 2010 at 07:05. #

…and now i found another qt-symbian-opensource-4.6.2.exe package (http://doc.trolltech.com/4.6/install-symbian-installer.html)…? do i need it too or are qt-sdk/qt-win enought?

by mapick on March 8, 2010 at 08:48. #

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.

by iampeterbanjo on March 8, 2010 at 10:23. #

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)
http://www.forum.nokia.com/info/sw.nokia.com/id/4a7149a5-95a5-4726-913a-3c6f21eb65a5/S60-SDK-0616-3.0-mr.html
2) here you find all possible immaginable original qt downloads
ftp://ftp.qt.nokia.com
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
http://qt.nokia.com/developer/new-qt-apis/view

…and it started!

by mapick on March 9, 2010 at 01:54. #

…i forget

1) you must install on your device the qt_installer.sis you find in qt directory

2) here there are all the “qt official installation guides”
http://qt.nokia.com/doc/4.6/installation.html

…and good luck!

by mapick on March 9, 2010 at 02:35. #

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?

by art on May 8, 2010 at 13:24. #

@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. :-)

by iampeterbanjo on May 19, 2010 at 12:21. #

thanks mapick. that’s awesome!

by iampeterbanjo on May 19, 2010 at 12:23. #

Leave your comment

Required.

Required. Not published.

If you have one.