>Since I just got my new computer up and running, I wanted to start using Qt. Another new, for me, is Vista, so I decided to get my commercial Qt license up and running using MinGW in Vista. The proved to be a small challenge so I’ve documented my steps here.
First of all, put your license file in your user directory and try to rename it to .qt-license. Notice that the file explorer won’t let you do that. Apparently the only dot denotes the start of the file ending, so in Vista’s eyes, a file starting with a dot has no name. The solution is, as always, to use a command prompt and good old ren.
I’ve downloaded MinGW and the commercial Qt sources for win32. These are installed/extracted into the Coding directory located in my home directory (being C:\Users\Thelin in my case). MinGW lives in Coding\MinGW while Qt is in Coding\qt-win-commercial-src-4.4.1.
Building
Let’s continue by using a command prompt and set some environment variables to point out these facts. We need to include MinGW in the PATH variable. Then Qt needs the QTDIR and QMAKESPEC variables to get its foothold.
set PATH=%PATH%;C:\Users\Thelin\Coding\MinGW\bin
set QTDIR=C:\Users\Thelin\Coding\qt-win-commercial-src-4.4.1
set QMAKESPEC=%QTDIR%\mkspecs\win32-g++
As we are used to from Unix, we then configure Qt before building it. This is straight forward, but I’ve included my configure line for completeness.
configure.exe -debug-and-release -shared -plugin-sql-sqlite -qt-zlib -qt-libpng -qt-libjpeg -no-libtiff -no-gif -no-dsp -no-vcproj -assistant-webkit
The last step of the configuring is the construction of QMake for your configuration. It is good to know that the file pbuilder_pbx.cpp takes ages to build (see TaskTracker #162299). Apparently by design.
When QMake has been built, simply do as told. Run mingw32-make to build Qt. I choose to add the argument -j4 to utilize my CPU cores better. Don’t know if it improves the build time much but it makes me feel good.
Now, all that is left is to add %QTDIR%/bin to PATH and to try the Qt demos. However, keep on reading if you want to make the installation easier to use.
set PATH=%PATH%;%QTDIR%\bin
Command Line Conveniences
To make it a bit easier to get up and running with Qt, we will create two batch files. First, qt-vars.bat, that initializes the environment variables as shown in this text (gather all the lines starting with set in a file). To make things fancy, you can create a short-cut to this file. Set it to run cmd /K qt-vars.bat to end up with an intialized command prompt – quite nice.
The second batch file that I mentioned before is make.bat. Make it run mingw32-make and place it somewhere in path. If you want to be able to use command line arguments, pass on a few %1 %2 %3 and so on to MinGW. This will allow you to type make -j4, instead of prefixing it with mingw32- every time. You can place this file either in Qt’s bin directory, or with the MinGW executables.
Eclipse
Since the Windows command prompt leaves quite alot to wish for, I prefer trying something else for a change. It it possible to use cygwin or other shell replacements, but hey, we’re in a graphica environment, so why no try to use something grapical such as Eclipse.
Qt integrates quite well with Eclipse. Start by downloading Eclipse for C/C++, or just the standard edition with and the C/C++ support module. Then download the Qt integration. Commercial license holders will find it in their personal download directory.
Once all the installers have been run, start Eclipse through the Qt Eclipse Integration item on the Windows start menu. Then select File – New – Project… and choose to create Qt application. This will prompt you to specify what Qt version to use in the dialog shown below. Simply point out the version you just built and you are ready to go.
The Qt integration works great – but sometimes you can get a feeling of nausea. For example, it is not clear from the start how to execute the result of your project. But, then you can always revert to the good old command line.