Wednesday, 24 October 2012

Build Qt source 64-Bit from Visual Studio 2010

This is a quick post, how to build Qt [open]source 64-Bit, with Visual Studio 2010 Command Line.

Stuffs I have used to build this,
* Visual Studio 2010 : Visual Studio x64 Win64 Command Prompt
* Qt Source Code version: qt-everywhere-opensource-src-4.8.1
* Active Perl 5.16.1 64-Bit
* Windows 7 64-Bit

Note: If you are building Qt source 4.8.0 and above, you must install Perl in your system.

Download below piece of codes,
1. Download Qt Source code from >> here <<
I have chosen "" for my build.

2. Download and install Active Perl 64-bit from >> here << 
I have chosen Active Perl version 5.16.1 - 64-Bit build.

Now, let's start building.

>> Unzip the Qt source code into the directory where you would like to install Qt.
In my case I have kept whole source code in C:\Qt64\4.8.1\ directory.

>> Let's avoid setting PATH manually for Qt source. Let's have a batch file to do that. Create a new file and rename it as QtEnvBat.bat
Copy and paste below code into the batch file and save it,
@echo off
set QTDIR="C:\Qt64\4.8.1"
set QMAKESPEC="win32-msvc2010"
set PATH=%PATH%;"C:\Qt64\4.8.1\bin"
echo Successfully set all Qt Env variables.

where "C:\Qt64\4.8.1" is a directory where my Qt source code is present.
Place this batch file inside C:\Qt64\4.8.1\ directory.

>> I will consider, you have successfully installed Active Perl in your machine.

>> Now open Visual Studio Command Prompt. Goto Start > All Programs > Microsoft Visual Studio 2010 > Visual Studio Tools > Visual Studio x64 Win64 Command Prompt
Remember, right click and choose "Run as Administrator".

>> From VS command prompt, navigate to C:\Qt64\4.8.1\ with CD command,

cd c:\Qt64\4.8.1\

Now run the batch file you have prepared just before.


Next, execute below command,

configure -debug-and-release -opensource -platform win32-msvc2010

sit back and have a cup of coffee, and some snacks too, because this may take few minutes to couple of hours !!!

Once above command is successful, Qt source code is successfully configured and ready to build now.

Next is final touch-up and most important command,

nmake all

allow your machine to build whole Qt source code. This is expected to take minimum of 4-5 hrs for an ideal machine.

Note here, some people prefer "Jom" builder over "nmake", but I prefer VS2010 comand prompt as it is sophisticated and powerful yet.
However, you can download latest Jom from here, and give a try.

Hope this post helped.

updated on - 30/10/2012

once you are done building, you need to install it. Use below command,

nmake install

Please note, even internally nmake install is copying build files to release directory, it is important you run this command if you are deploying your Qt resources into client machine.

No comments:

Post a Comment