понеделник, 11 януари 2010 г.

Create, open and build QT4 projects with Visual Studio 2005

Note: If you won't use QT Creator at all download only source packages of QT4, you don't need the whole SDK
  • Install it in the default offered directory C:\QT\2009.05 (will be used with QT Creator).
  • Copy the content of this folder to C:\QT\4.6.0-vc (will be modified and used with Miocrosoft Visual Studio 2005).
  • Find the file VCVARS32.BAT - the path depends on the Visual Studio installation, usually it's in C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat, open command prompt and execute it.
> "C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat"
  • Delete files C:\QT\4.6.0-vc\qt\src\script\tmp\moc\debug_shared\mocinclude.tmp and C:\QT\4.6.0-vc\qt\src\script\tmp\moc\release_shared\mocinclude.tmp (speciality for 4.6.0 version)
(... else on the 50th minute of the QT4 sources building you will take messages:
api\qscriptextensionplugin.h(43): Error: Undefined interface
NMAKE : fatal error U1077: 'C:\QT\4.6.0-vc\qt\bin\moc.exe' : return code '0x1'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 8\VC\BIN\n
make.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: 'cd' : return code '0x2'
Stop.)
  • In the command prompt write:
> cd c:\qt\4.6.0-vc\qt
> configure -no-sql-sqlite -no-qt3support -no-opengl -platform win32-msvc2005 -no-libtiff -no-dbus -no-phonon -no-phonon-backend -no-webkit
>o
>y
(... it takes 10 - 15 minutes, at the end you should receive message:
"Qt is now configured for building. Just run nmake.
To reconfigure, run nmake confclean and configure.")
> nmake
(... it takes 2 hours and 30 minutes to build QT sources with Visual Studio compiler...)
  • Download Visual Studio Add-in from http://qt.nokia.com/downloads/visual-studio-add-in and install it.
  • On "My Computer" -> right mouse button "Properties" -> tab "Advanced" -> button "Environment Variables" -> section "System variables" -> button "New" -> variable name: QTDIR , variable value: c:\qt\4.6.0-vc\qt
  • Restart the computer
  • Run Visual Studio 2005 - in it after installing the add-in there is menu Qt. From it: Qt -> Qt Options -> tab Qt Versions -> button "Add" -> path "c:\qt\4.6.0-vc\qt"
Now you are ready to make QT projects in Visual Studio. Enjoy!