Obtaining GPL'ed Qt for Windows
OBSOLETE: Starting with this modified version of Qt 4.3 is no longer required. The GPL source provided by Trolltech can be compiled using Visual Studio on Windows. We are leaving this deprecated page here for historical reasons.
Overview
On Win32 operating systems, Trolltech has adopted a policy of crippling their GPL'd "open source edition" of Qt 4.2 so that it can only be built using the MinGW environment, which is based upon the gcc compiler ported to Win32. Developers who wish to use Qt with Microsoft compilers would normally be encouraged to purchase the commercial edition of Qt, see the Trolltech FAQ entry on this subject. For convenience to those who wish to use Microsoft compilers, we are providing a patched version of the Qt GPL sources that can be built with Microsoft tools.
Installation
- Download paraview-qt-win-opensource-src-4.2.3.zip, saving it to a convenient location (c:\qt is strongly recommended).
- Expand the paraview-qt-win-opensource-src-4.2.3.zip file.
- Start a DOS shell, and cd to the c:\qt\paraview-qt-win-opensource-src-4.2.3 directory.
- The DOS shell should have your desired compiler environment
- For example, "Start->Programs->Microsoft Visual Studio 2005->Visual Studio Tools->Visual Studio 2005 Command Prompt"
- Run the Qt configure script (not configure.exe):
c:\qt\paraview-qt-win-opensource-src-4.2.3> qconfigure.bat
- From this point forward, compilation and deployment of the Qt libraries should proceed normally. Begin compilation using the in-console instructions provided by the configuration process.
- If you are using the Microsoft Visual Studio 2005 compiler with service pack 1 and get compile errors like the ones shown below, you have two options (listed after the errors).
Microsoft (R) Program Maintenance Utility Version 8.00.50727.762 Copyright (C) Microsoft Corporation. All rights reserved. cl -c -Yc -Fptmp\qmake_pch.pch -Fotmp\qmake_pch.obj -nologo -Zm200 -GS -O1 -MD -DNDEBUG -GR -EHsc -W3 -DUNICODE -DQT_LARGEFILE_SUPPORT -DWIN32 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DQT_BUILD_QMAKE -DQT_BOOTSTRAPPED -DQT_NO_TEXTCODEC -DQT_NO_LIBRARY -DQT_NO_STL -DQT_NO_COMPRESS -DQT_NO_UNICODETABLES -DQT_NO_GEOM_VARIANT -DQT_NO_DATASTREAM -DQMAKE_OPENSOURCE_EDITION -DQT_NODLL -DQT_NO_THREAD -DQT_NO_QOBJECT -I"../src/corelib/arch/generic" -I"generators" -I"generators\unix" -I"generators\win32" -I"generators\mac" -I"../include" -I"../include/QtCore" -I"../src/3rdparty/md5" -I"../qmake" -I"..\mkspecs\win32-msvc2005" -TP qmake_pch.h qmake_pch.h c:\qt\qt-win-opensource-src-4.2.3\include\qtcore\../../src/corelib/tools/qhash.h (866) : error C2244: 'QMultiHash<Key,T>::replace' : unable to match function definition to an existing declaration c:\qt\qt-win-opensource-src-4.2.3\include\qtcore\../../src/corelib/tools/qhash.h(851) : see declaration of 'QMultiHash<Key,T>::replace' definition 'QHash<Key,T>::iterator QMultiHash<Key,T>::replace(const Key&,const T &)' existing declarations 'QHash<Key,T>::iterator QMultiHash<Key,T>::replace(const Key&,const T &)' c:\qt\qt-win-opensource-src-4.2.3\include\qtcore\../../src/corelib/tools/qhash.h (870) : error C2244: 'QMultiHash<Key,T>::insert' : unable to match function definition to an existing declaration c:\qt\qt-win-opensource-src-4.2.3\include\qtcore\../../src/corelib/tools/qhash.h(852) : see declaration of 'QMultiHash<Key,T>::insert' definition 'QHash<Key,T>::iterator QMultiHash<Key,T>::insert(const Key&,const T &)' existing declarations 'QHash<Key,T>::iterator QMultiHash<Key,T>::insert(const Key&,const T &)' NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 8\VC\BIN\cl.EXE"' : return code '0x2' Stop.
You can either get hotfix KB930198 from Microsoft, or you can make the following changes to two files in your Qt source code.
in qhash.h:
// Fix for VS 2005 SP1 typedef QHash<Key, T>::iterator iterator; inline typename iterator replace(const Key &key, const T &value); inline typename iterator insert(const Key &key, const T &value); // inline typename QHash<Key, T>::iterator replace(const Key &key, const T &value); // inline typename QHash<Key, T>::iterator insert(const Key &key, const T &value);
In qmap.h:
// Fix for VS 2005 SP1 typedef QMap<Key, T>::iterator iterator; inline typename iterator replace(const Key &key, const T &value); inline typename iterator insert(const Key &key, const T &value); // inline typename QMap<Key, T>::iterator replace(const Key &key, const T &value); // inline typename QMap<Key, T>::iterator insert(const Key &key, const T &value);
- Configure your PATH to point to c:\qt\paraview-qt-win-opensource-src-4.2.3\bin.
- Use CMake to build ParaView normally.
Advanced Users
For the curious, here is the procedure used to patch the Qt GPL sources:
The QtWin Project provides a set of patches that allow the Qt GPL libraries to be built with Microsoft compilers.
- Download qt-win-opensource-src-4.2.3.zip from Trolltech.
- Expand qt-win-opensource-src-4.2.3.zip in a convenient location such as c:\qt. This will create a c:\qt\qt-win-opensource-src-4.2.3 directory containing the full Qt sources.
- Download acs-4.2.3-patch1.zip from the QtWin project.
- Move the downloaded file acs-4.2.3-patch1.zip to the c:\qt\qt-win-opensource-src-4.2.3 directory.
- Expand acs-4.2.3-patch1.zip in place.
- Run installpatch42.bat in the c:\qt\qt-win-opensource-src-4.2.3 directory.
- Voila!
Note: ensure that your archive utility restores permissions and ownership for the zip file contents. Some tools (such as cygwin unzip) don't do this by default, which will lead to compile errors when you compile the sources later-on.