Qt on Windows
From Wiki for RobotCub and Friends
Contents |
Introduction
This short manual shows how to use the open source Q... edition from http://qtwin.sourceforge.net with Visual Studio VC++ 2005.
The original installation howto is available at: http://qtwin.sourceforge.net/qt3-win32/compile-msvc-2005.php
The howto presented here adds some details.
Compiling Q...
Checkout the sources from the subversion repository at: https://qtwin.svn.sourceforge.net/svnroot/qtwin/qt-3/trunk for example by using tortoise svn.
I assume you have installed the Visual C++ Express (VC 8) and windows platform sdk (see YARP and Visual Studio 2005 Express Edition) or Visual Studio 2005 altogether.
Open the Visual Studio Command Prompt available in your start->programms->visual studio menu.
Set the following variables:
Setup Q... environment (here sources in C:\source\qt-3, please adjust the path to your needs)
C:\source> set QTDIR=C:\source\qt-3 C:\source> set PATH=%QTDIR%\bin;%PATH% C:\source> set QMAKESPEC=win32-msvc.net set INCLUDE="C:\Program Files\Microsoft Visual Studio 8\VC\include";"C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include" set LIB=%LIB%;"C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib"
Note: if you are using Microsoft Visual C++ 2008 Express Edition version 9.0, the SDKs are bundled and you need to substitute the following for the above set INCLUDE and set LIB.
Set INCLUDE="C:\Program Files\Microsoft Visual Studio 9.0\VC\include";"C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include" Set LIB=%LIB%;"C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib"
Configure and build the source:
C:\source> cd C:\source\qt-3 C:\source> configure.bat
(This might fail at some point.)
In any case open now the qt_mt.vcproj project file in qt-win\src and compile within VC++. Set to DEBUG mode if you want to be able to debug later. I needed to compile the Q... sources inside Visual Studio to be able to debug applications built on top of Q... . When Q... was not compiled 'inside' Visual Studio the manifests were not embedded correctly into the executables and applications built on top of Q... failed to start when compiled in debug mode.
Note: if you are using Microsoft Visual C++ 2008 Express Edition version 9.0, and possibly other versions too, you need to be aware of the following issues.
- Before you build Qt using the qt_mt.sln file (which is generated when you convert the qt_mt.vcproj file), you must set the QTDIR environment variable to, e.g., C:\source\qt-3. If you don’t the compiler won’t be able to find essential .h files and the build will fail. Also, add the path to the \bin directory to the PATH environmental variable and set the QMAKESPEC environment variable to win32-msvc.net
-
winable.hwas missing from the Qt sources but you can download it here and copy it to the qt-3/include directory.
- Build qt-mt3.lib (note: - not _) using qt_mt.sln. First check that the configuration is set to .lib before building (Project > Properties > Configuration Properties > General > Configuration Type). Then select which configuration you want: Release or Debug. Note that both the Release and Debug configuations creates a library called qt_mt.lib and puts it in /bin, not in /lib. You should move qt_mt.lib from /bin to /lib rename it qt-mt3.lib (note: - not _).
- Build qtmain.lib using qtmain.sln converted from qtmain.vcprog. The behaviour of the Release and Debug configuations of qtmain.sln is different. The Debug configuration puts all the targets in the right places, e.g. qtmain.lib is placed in /lib but the Release configuration puts qtmain.lib in /src/Release. If you want the release version, you should move qtmain.lib from /src/Release to /lib.
- You also need to build the uic.exe executable. Open the uic.vcproj file in /tools/designer/uic, convert it to uic.sln, and build the executable. Be sure to check that the configuration is set to .exe and not .lib before building (Project > Properties > Configuration Properties > General > Configuration Type). The Debug configuration puts the target in the right places, e.g. uic.exe is placed in /bin but the Release configuration puts uic.exe in /tools/designer/uic/Release. If you want the release version, you should move uic.exe from here to /bin.
As of 070225 there was a bug(?): I needed to comment out the unistd.h header in the moc_lex.cpp file. (The unistd.h header is a POSIX header and not available on the windows platform. If project file generation fails because of this header you might try to comment it out.)
src\moc\moc_lex.cpp //#include <unistd.h>
Further Informations from the Original HowTo
The script first creates link_includes.exe and configure.exe which are needed for bootstrap the build process. link_includes copies all relevant Qt headers into the include-directory. configure.exe is the replacement for the ./configure-script under Unix/Linux. After that, qmake.exe is build and the compilation gets started.
Configure knows some of the parameters of the x11 release configure script like -fast or -verbose. For a full list see bin\configure.exe -help.
This should build the whole Q../Free release. If it breaks you can restart compiling with
C:\source\qt-3> nmake [< target >]
for a list of all available targets see the toplevel Makefile
Q... Executables
Start Q... applications:
C:\source\qt-3> designer C:\source\qt-3> assistant C:\source\qt-3> linguist C:\source\qt-3> cd tutorial\t1 C:\source\qt-3\tutorial\t1> t1

