This post is a step-by-step guide on how to compile Qt 4.x.x with MSVC 2010.

Although we use Qt 4.7.1 as an example (for historical reasons), you can also find suggestions on building newer versions of Qt by MSVC 2012 and even by Intel Compiler for both platforms x86 and x64. All kudos go to numerous contributors, who spend their time to do all the tweaking and testing (see updates below).

In particular there are instructions on how to build Qt 5 for x64 platform contributed by Vincenzo Mercuri.

Updates

December 21, 2012Vincenzo Mercuri shared instructions for building Qt 5.0.0 in x64 configuration.

December 19, 2012Vincenzo Mercuri informed that he have compiled Qt 4.8.4-x64 by the guide. Also he shared his instructions for building Qt with Intel C++ Compiler into static library.

November 4, 2012: As reported by Mike Peltonwhatnick and Borislav Stanimirov32 & 64bit versions of Qt 4.8.3have been successfully compiled by this guide, by both Visual Studio 2010 & 2012. Be aware that Qt might not be adjusted yet for Windows 8 (as reported here).

June 4, 2012: As reported by WenqingQt 4.8.2 has been successfully compiled by this guide.

April 5, 2012: As reported by Snouty, 32bit version of Qt 4.8.1 has been successfully compiled by this guide.

December 20, 2011: As reported by Evon, 64bit version of Qt 4.8.0 has been successfully compiled by this guide. To do 64bit compilation, please use Visual Studio x64 Win64 Command Prompt (2010) in step 8. Also please use jom 1.06 and don’t forget to install Service Pack 1 for Visual Studio.

September 16, 2011Qt 4.7.4 has been successfully compiled by this guide.

August 14, 2011: In order to build Qt for 64 bits just use Visual Studio x64 Win64 Command Prompt (2010) in step 8. Also install Service Pack 1 for Visual Studio 2010 beforehand – it fixes few bugs related to x64 compilation.

July 18 2011Qt 4.7.3 and Qt 4.8 (beta) has been successfully compiled by this guide. Just replace version number where applicable.

Build instructions

  1. Visual C++ 2010 contains all necessary SDKs for Qt compilation. However if you plan to use Qt with Phonon you need to install DirectX SDK first.
  2. Install Perl if you are going to compile Qt >= 4.8.0
  3. Download and extract Qt 4.7.1 Source Code. (Qt 4.8.0 or Latest snapshot).
  4. Copy contents of the folder qt-everywhere-opensource-src-4.7.1 to the directory where you intend to install Qt. In our case this is C:\Qt\4.7.1.
  5. Set up environmental variables
    QTDIR=C:\Qt\4.7.1
    QMAKESPEC=win32-msvc2010
  6. Update PATH variable to include %QTDIR%\bin
  7. Download the latest version of jom.
  8. Extract jom files to C:\Qt\jom folder
  9. Start Visual Studio 2010 Command Prompt:
    Start > Programs > Microsoft Visual Studio 2010 > Visual Studio Tools > Visual Studio Command Prompt.
  10. Run following commands in it (every line is a different command: type it then press Enter):
    cd c:\Qt\4.7.1
    configure -debug-and-release -opensource -platform win32-msvc2010
    ..\jom\jom.exe -j N

    Where N is number of CPU cores you want to utilize for Qt compilation. Larger is better.

  11. Download and install Qt Visual Studio Add-in.
  12. Run Visual Studio 2010. Integrate just compiled Qt to IDE using menu Qt > Qt Options > Qt Versions > Add

Usually compilation takes about 10 hours, but thanks to jom and Intel SSD drive it took only 2 hours 40 minutes on my machine (Windows 7, 64bits)

Remarks

* Jom is nmake replacement for Qt compilation on multi-core CPU. Its parameter -j N allows to setup number of parallel processes for compilation. Number of physical CPU cores is a good choice for N.

** Do not forget to use /d switch if you want to change drive in command prompt, e.g: cd /d d:. Usual cd d: does not work anymore – a little “surprise” from Microsoft.

Contributions

* As Evon pointed in comments, Qt folder has huge size (approx. 7GB) after compilation. One can safely shrink its size by deleting temporary files created during the process. Once compiled Qt doesn’t depend on these intermediate files – and they can be erased without affecting Qt functionality. Run as last command in step 10:

..\jom\jom.exe clean

Note that PDB files will be deleted too (the files are rarely needed, only for debugging of Qt itself).

** Rob provided his compilation script based on nmake with multi-core support.

http://www.holoborodko.com/pavel/2011/02/01/how-to-compile-qt-4-7-with-visual-studio-2010/

How To Compile Qt with Visual Studio 2010的更多相关文章

  1. How To Compile Qt with Visual Studio

    How To Compile Qt with Visual Studio FEBRUARY 1, 2011 This post is a step-by-step guide on how to co ...

  2. [转]Visual Studio 2010 中安装Qt 5.1

    截至目前(2013年7月12日)为止,Qt 的最高版本为Qt5.1,在该版本中已经将Qt Creator与Qt Lib集成在一个文件夹中,因此安装的时候较为方便,只需安装一个即可.因为Qt具有超强的可 ...

  3. Qt环境搭建(Qt Creator)+Visual Studio

    1.http://www.cnblogs.com/ranjiewen/p/5318768.html 简述 经常有人问我编写Qt程序时使用什么IDE,其实这个真的很难回答(各有所长),只能说看个人爱好了 ...

  4. 【转】Setting up SDL 2 on Visual Studio 2010 Ultimate

    from: Lazy Foo'Productions - Setting up SDL 2 on Visual Studio 2010 Ultimate 1)First thing you need ...

  5. 【转】Setting up SDL Extension Libraries on Visual Studio 2010 Ultimate

    FROM:http://lazyfoo.net/tutorials/SDL/06_extension_libraries_and_loading_other_image_formats/windows ...

  6. [入门级] 基于 visual studio 2010 mvc4 的图书管理系统开发初步 (二)

    [入门级] 基于 visual studio 2010 mvc4 的图书管理系统开发初步 (二) Date  周六 10 一月 2015 By 钟谢伟 Category website develop ...

  7. [入门级] visual studio 2010 mvc4开发,用ibatis作为数据库访问媒介(一)

    [入门级] visual studio 2010 mvc4开发,用ibatis作为数据库访问媒介(一) Date  周二 06 一月 2015 By 钟谢伟 Tags mvc4 / asp.net 示 ...

  8. 用C#语言在Visual Studio 2010里开发一个自定义的PowerShell Cmdlet

    1. 打开Visual Studio 2010 2. 新建一个基于Class Library的项目 3. 给项目起个名字然后OK 4. 为项目添加下列Reference System.Manageme ...

  9. 【处理手记】VS2010SP1安装不上Visual Studio 2010 SP1 SDK的解决办法

    想写个VS插件,需要安装VS的SDK,VS2010SP1对应的SDK自然是Visual Studio 2010 SP1 SDK,下载页面: https://www.microsoft.com/en-u ...

随机推荐

  1. 转:SVN 出现This client is too old to work with working copy...错误

    本地进行SVN客户端版本更新,但是之前一些代码是用的旧svn客户端提交的,这时候进行代码更新或者提交代码可能会出现错误,我这边是NetBeans中提交代码就出现了以下错误:This client is ...

  2. 【转】Android下编译jni库的二种方法(含示例)

    原文网址:http://blog.sina.com.cn/s/blog_3e3fcadd01011384.html 总结如下:两种方法是:1)使用Android源码中的Make系统2)使用NDK(从N ...

  3. C#开发者准备的通用性代码审查清单

    这是为C#开发者准备的通用性代码审查清单,可以当做开发过程中的参考.这是为了确保在编码过程中,大部分通用编码指导原则都能注意到.对于新手和缺乏经验(0到3年工作经验)的开发者,参考这份清单编码会很帮助 ...

  4. 原生javascript添加引用js文件

            function addScriptTag(src) {                         var script = document.createElement(&qu ...

  5. YUM配置

    一.yum环境的本地源搭建(基于VSFTP): 1)安装vsftp;    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@         [root ...

  6. cookielib模块基础学习

    # -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' import cookielib #主要用于处理http客户端的co ...

  7. Android系统进程Zygote启动过程的源代码分析

    文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/6768304 在Android系统中,所有的应用 ...

  8. [HeadFirst-JSPServlet学习笔记][第一章:前言与概述]

    第一章 前言与概述 web服务器做什么? 答:接收客户请求,然后向客户返回结果 web客户做什么? 答:此处客户指浏览器,web客户允许用户请求服务器上的某个资源,并向用户展现请求的结果. html ...

  9. Js获取Gridview中Dropdownlist选中状态

    在Gridview中加入Dropdownlist模板列,加入DropDownlist 是一种常用的操作,其中涉及到如何获取选择项和Gridview重新绑定两个要点. 如图 前台代码如下 <%@ ...

  10. js控制html5 audio的暂停、播放、停止

    <!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <meta name ...