Installing Qt 4.4.3 On Windows (Various Methods)

Qt GUI Toolkit is an opensource toolkit using C++ and other languages to code, it is the best GUI library there is. Qt allows you to make Windows, Linux, or Mac programs that work great. We'll explain how to install it on windows (it's much easier in linux).

Download the latest Open Source Windows version for Qt.

Make sure you download the correct one, ending in something like:
qt-win-opensource-4.4.3-mingw.exe (MinGW) (the exe version works best)

Install the program, if you don't have MinGW compiler installed or don't know what it is, download and install that as well (the Qt installer will give you this option).

QMake or Standard Qt Non-Static Method

1) Now once Qt is installed, you should check your environment variable settings of your computer:
1. Right click -> My Computer
2. Properties -> Advanced Tab
3. Environment Variables button
Add the following variables under system variables (correct the paths to suit your needs):
QTDIR -> C:\Qt\4.4.3
MINGW -> C:\MinGW
(Simply edit this one, it exists already) append the following for PATH -> ;%QTDIR%\bin;%MINGW%\bin;
(Use semi-colons after each statement)
(Note: If you have Qt3 installed you cannot use the QTDIR variable)

2) Ok now you should be set, Start->Run->"cmd" and now in the console go to C:\Qt\4.4.3
or wherever your Qt is installed, and first test the variable "QTDIR" by typing "echo %QTDIR%" it should display your path to Qt.

3) Next type in your platform specific configuration option (inside C:\Qt\4.4.3). If you have Windows, use:
configure -platform win32-g++
(Note: To use nmake, or Microsoft Visual Studio, then use configure -platform win32-msvc instead)

It should start making QMake and getting it ready for you. If you get any errors, your path is not set up correctly, and it cant find the Qt Directory. Trust me if you do it correctly you should have no trouble.

4) Now you can compile projects by using the console to go to your project folder, and typing "qmake -project" (to initialize the .pro file, only need to do this once)
then "qmake" (to update the project file)
then "make" (compile and link; no quotes needed)
If make doesn't work then your MinGW path is not set up correctly and it cant find MinGW\bin.

Make sure you can "echo %QTDIR%" or "echo %MINGW%" if nothing is coming up, try restarting command prompt!

Using Notepad++ Makes it Easy!

Now after you have created QMake in the previous steps, use a free editor like Notepad++ Installer. The best IDE I've ever used.

Dev-C++ Free Mingw IDE

1) Download and install Dev-C++ (4.9.9.2), try not to use spaces where ever you install.
2) Use the Qt Template download attachment found at the bottom of this page.

By downloading and extracting the files to your Template folder of Dev-Cpp (ex: C:\Dev-cpp\Templates\). Remember to change all your paths from 4.3.3 to whatever your version is, and whatever your path is (ex: C:\Qt\4.3.3 etc)
3) Create a new project in Qt, and definitely use the Qt tab and click on Qt Icon, name your project, and start it. Doing this will make the template file take effect.
4) You need to add the Qt libraries to your project's directories. Go to Tools->Compiler Options and then the Directories tab. Then in the libraries sub-tab, add the path to the Qt libraries (e.g: C:\Qt\4.3.3\lib).
5) Now you should be able to press Compile and run, and get a running Qt application. If not, you forgot a step, or you didn't set the paths correctly.
6) Also remember to include your QtCore4.dll, QtGui.dll and other related dlls in your project folder to avoid errors.

Microsoft Visual C++ Method

You will need to buy the commercial version of Qt, or find a place to download the MSVC project for it, usually denoted by .vcproj or .sln. After that it is not difficult to set up.

Standard Qt Static Method (no DLLs needed)

In this method you will be using qmake and mingw, but this time you won't need to include DLLs of Qt wherever you go, instead they will be added onto your main program, making it bulkier, but at least you won't have to carry around large DLLs.

MingW (Devcpp, code::blocks, notepad++, qmake)
1) Edit mkspecs (c:\Qt\4.4.3\mkspecs\win32-g++\qmake.conf):
Find: QMAKE_LFLAGS = -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc
Replace (to add -static): QMAKE_LFLAGS = -static -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc

2) Now in your Qt folder (C:/Qt/4.4.3/) in command prompt, type:
configure -static -release -no-exceptions
then type:
mingw32-make sub-src

This may take a while.

Now in your .pro file of your projects, make sure you include this line:
CONFIG += static
so that it will compile your project them statically (or CONFIG += staticlib for .lib compiles).
Microsoft Visual Studio C++ Static
If you use the opensource version, download the Win Patch.

Also use Building on MSVC tutorial to change your mkspecs first.

In your Qt folder with command prompt, type:
configure -static -release
and when finished:
nmake sub-src

Eclipse and Qt C++

If you use Eclipse for Windows or Linux, you can download the Eclipse Integration Package for Qt C++ from the trolltech site.

If you continue to have problems, please drop by our programming forums.

AttachmentSize
Qt4.4.3-Template.zip11.49 KB
naresh's picture

Hello sir, My name is

Hello sir,
My name is Naresh. Recently I heard about Qt4 tool and i am interested in it. So i downloaded Qt4 precompiled package and installed it in Windows.
I set my Environment variables like this:
PATH:C:\Qt\2010.02.1\bin;C:\2010.02.1\mingw\bin;
MINGW:C:\Qt\2010.02.1
QTDIR:C:\Qt\2010.02.1
QTMAKESPEC: win32-g++

Now I tried to configure Qt in command prompt. I followed your instructions. Then it showed me to type mingw32-g++.After typing it i got the following errors:
kernel\qboxlayout.cpp:1518: internal compiler error: in size_of_die, at dwarf2ou
t.c:7630
Please submit a full bug report,
with preprocessed source if appropriate.
See for instructions.
mingw32-make[2]: *** [tmp/obj/debug_shared/qboxlayout.o] Error 1
mingw32-make[2]: Leaving directory `C:/Qt/2010.02.1/qt/src/gui'
mingw32-make[1]: *** [debug-all] Error 2
mingw32-make[1]: Leaving directory `C:/Qt/2010.02.1/qt/src/gui'
mingw32-make: *** [sub-gui-make_default-ordered] Error 2

Give me a solution for my problem.

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account associated with the e-mail address you provide, it will be used to display your avatar.