Compiling Qt4 on Windows
From PsiWiki
Disclaimer: These instructions are unofficial and may or may not work for you.
NOTE: For official Qt4 build instructions, see Build_Instructions_Qt4.
This article describes how to get Qt4 and build it on Windows platform. If you intend to get Qt3 and build it on Windows, please consult Psi/Windows build instructions.
Even though Qt4/OpenSource comes with precompiled release version of Qt4 for MinGW, you have to compile it by yourself (esp. when you use compiler different than MinGW) to have both debug and release versions of Qt4.
Contents |
[edit] Available compilers
Qt4 can be compiled using a variety of C++ compilers available on Windows platform:
- MinGW
- Borland C++ or Borland C++ Builder
- Microsoft Visual C++ .NET 2003
- Microsoft Visual C++ 2005
Notes:
- Compilers other than MinGW are not officially supported by Qt4/OpenSource or by the Psi Development Team.
- MinGW is one of ports of gcc/g++ compilers for Windows platform. This compiler will be used for creating official Psi Windows builds (using Qt4).
- Microsoft Visual C++ .NET 2003 compiler has been released for free as Microsoft Visual C++ Toolkit 2003 - can be used to compile Qt4/Psi(Qt4) but with no support from Qt4/OpenSource or from the Psi Developers
- Borland C++ and Borland C++ Builder compilers were not tested yet.
- Microsoft Visual C++ .NET (a.k.a. Microsoft Visual C++ .NET 2002) may also be able to compile Qt4.
- Microsoft Visual C++ 6.0 (with any Service Pack and Platform SDK installed) is unable to compile Qt4.
- You cannot use the freely downloadable Microsoft .NET Framework SDK to compile Qt4.
[edit] Compiling Qt4
[edit] Compiling Qt4 using MinGW (supported)
Open MinGW development console by running Start|Programs|Qt by Trolltech v4.1.0 (OpenSource)|Qt 4.1.0 Command Prompt.
New command-line window appears. Run following commands in that window:
cd C:\Qt\4.1.0\src
mingw32-make distclean (there is no Makefile here in version 4.1.3 --
suggest you just use the method in the Note below)
qmake
mingw32-make
This will clean Your Qt4 installation directory and build both debug and release versions of Qt4.
Note:
- Running Start|Programs|Qt by Trolltech v4.1.0 (OpenSource)|Qt 4.1.0 (Build Debug Libraries) might be tempting, but You may be stuck for several hours recompiling Qt4, templates, demos and other stuff and never ending the process. The above commands will lead to the desired effect much faster.
- As for Qt-4.1.0, I have to create qmake/tmp to make it work.
[edit] Compiling Qt4 using Microsoft Visual C++ (unsupported)
[edit] Patching Qt4/OpenSource using Qt/Win
If you want to use MinGW only, you don't have to patch Qt4/OpenSource with Qt/Win and therefore loose support from Trolltech and from the Psi Developers.
Download unofficial Qt/Win patch for Qt-4.1.x/OpenSource to Qt4/OpenSource installation directory and unpack it there. 5 new files will appear:
installpatch41.bat msvc_bcc32_41.patch patch.exe readme41.txt removepatch41.bat
Note:
- Please read readme41.txt file before continuing, as it may contain newer information than this page.
Run installpatch41.bat. Some more new files will appear. The most important is qconfigure.bat, which should be used instead of configure.exe to reconfigure Qt4.
Now, run qconfigure.bat according to Your selected C++ compiler:
qconfigure msvc.net
if you intend to use Microsoft Visual C++ .NET (a.k.a. Microsoft Visual C++ .NET 2002), Microsoft Visual C++ .NET 2003 or Microsoft Visual C++ Toolkit 2003,
qconfigure msvc2005
if you intend to use Microsoft Visual C++ 2005,
qconfigure borland
if you intend to use Borland C++ or Borland C++ Builder,
qconfigure g++
if you intend to use MinGW.
Note:
- Even though readme41.txt mentions about running
qconfigure msvc
if you intend to use Microsoft Visual C++ 6.0, Qt4 compilation will fail (due to flaws in template support in Microsoft Visual C++ 6.0 compiler).
[edit] Compiling Qt4 using Microsoft Visual C++ .NET
Open Microsoft Visual C++ .NET development console by running Start|Programs|Microsoft Visual .NET 2003|Visual Studio .NET Tools|Visual Studio .NET 2003 Command Prompt.
Note:
- Depending on your actual Microsoft Visual C++ .NET version (Microsoft Visual C++ .NET, Microsoft Visual C++ .NET 2003 or Microsoft Visual C++ Toolkit 2003) the names may slightly differ.
New command-line window appears. Run following commands in that window:
cd C:\Qt\4.1.0 qconfigure msvc.net nmake
This will clean Your Qt4 installation directory and build both debug and release versions of Qt4 for Microsoft Visual C++ .NET.
[edit] Compiling Qt4 using Microsoft Visual C++ 2005
Open Microsoft Visual C++ 2005 development console by running Start|Programs|Microsoft Visual 2005|Visual Studio 2005 Tools|Visual Studio 2005 Command Prompt.
New command-line window appears. Run following commands in that window:
cd C:\Qt\4.1.0 qconfigure msvc2005 nmake
This will clean your Qt4 installation directory and build both debug and release versions of Qt4 for Microsoft Visual C++ 2005.