QT with Microsoft Visual studio VC++

I struggled a lot to find an efficient way to use QT with Microsoft Visual studio VC++ tool for programming graphics. Now as I manage to find the elegant solution for it which I want to share with the world.

If you found this compilation error in your Microsoft Visual Studio instead QT is installed in your system:

 1>LINK : fatal error LNK1181: cannot open input file 'qtmaind.lib'
 1>Project : warning PRJ0018 : The following environment variables were not found:

The reason for the above compilation error is that the QT binary path is not set.

I assume that your QT is installed in windows system partition “C:\Qt” like me else use your own path to Qt directory.

You need to SET the PATH of in SYSTEM VARIABLE given in ENVIRONMENT VARIABLE of Windows.

How to find ENVIRONMENT VARIABLE on windows?

1. Right Click on “My Computer” Icon.
2. click “Properties”
3. click on “Advanced” Option (“Advanced system setting” in case of Vista)
4. You will find the “Environment Variable” somewhere Below.
5. Please find “System Variable”.
6. Please find “PATH” inside “System Variable”.
7. Click on Edit button when you find PATH.
8. Copy & Paste the following PATH at the end of the line


9. Save & EXIT.

Look into the QT menu given in “Start -> All Programs”.

You’ll find a shortcut named “Visual Studio with Qt 4.7.1”. If not, the you can find it in c:\Qt\4.7.1\bin\ Batch script name


Double Click on “qtvars.bat”. It will

1) set the environment and exit.
2) OR/AND open “Microsoft Visual Studio linking with QT”

If Steps 1 & 2 works then you are ready to Programming. :)))


OR option is given because if you install QT first before installing Visual studio then the source code of the script will only look like

@echo off
rem This file is generated by the Qt installer

echo Setting up a Qt environment…

set QTDIR=C:\Qt\4.7.1
echo — QTDIR set to C:\Qt\4.7.1
set PATH=C:\Qt\4.7.1\bin;%PATH%
echo — Added C:\Qt\4.7.1\bin to PATH
set QMAKESPEC=win32-msvc2008
echo — QMAKESPEC set to “win32-msvc2008”

This script only set the environment variable.

So, you need to add some scripts to run Visual Studio with QT together. Please copy & paste the following code at the end of the script.

if not “%1″==”vsvars” goto ENDVSVARS
call “C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat”


if not “%1″==”vsstart” goto ENDVSSTART
call “C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat”
devenv /useenv

CAUTION: Don’t forget to give your own path & directory name of the Visual studio to the batch file.

Save & Exit.

Double click on the Script and boom.. it will work. 😀

If you want to run from command line then use the following command

c:\Qt\4.7.1\bin\qtvars.bat vsstart

Please put a shortcut on desktop in case you do not have any.

Hope this may help you!!! :)

  1 comment for “QT with Microsoft Visual studio VC++

  1. February 16, 2011 at 12:44 pm

    thanks budy :-)

Comments are closed.

Social Media Icons Powered by Acurax Wordpress Development Company