How To Compile Qt with Visual Studio

FEBRUARY 1, 2011

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.3 have 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的更多相关文章

  1. How To Compile Qt with Visual Studio 2010

    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. ...

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

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

  3. CMake结合Visual Studio中开发Qt应用程序注意事项

    Qt工程管理 个人比较偏爱于使用CMake来管理C++工程,因为只要编写一个CMakeLists.txt文件,就可以在Windows和Mac上生成各自的IDE工程.在Windows上, CMake自然 ...

  4. Qt Visual Studio Add-in 导出的 .pri 怎么用?

    今天咱们介绍一下 Qt Add-in 导出的 pri 文件怎么用.   一般需要导出这个文件, 主要应该是跨平台编译的需求, 所以这个文件里包含的东西会比较少, 咱们看下导出的文件是什么样子的: # ...

  5. Setup QT 5.5.1 + OpenCV 3.0 + Visual Studio 2013 on windows 10

    1. Install Visual studio 2013 community version which is free to use for personal usage. 2. Setup th ...

  6. qt 4.6.2 与visual studio 2005 集成(编译方法,以及中间遇到的问题)

    不知不觉在蒂森差不多半个月了,哈哈,时间过得很快,过得很充实,近来研究QT,首先嘛,肯定要学会安装了,这最基础的不会更不用说下面的啦.闲话少说,进正题,基本的安装步骤网上多的是,但参考一个大多数情况是 ...

  7. Qt环境搭建(Visual Studio)

    简述 经常有人问我编写Qt程序时使用什么IDE,其实这个真的很难回答(各有所长),只能说看个人爱好了,因为我两个都用,而且两个都很喜欢(比较多情吧O(∩_∩)O~)! 下面将进行Qt Creator与 ...

  8. C++问题-Qt Visual Studio Add-in

    问题现象:用VS打开其他人的项目提示如下:Qt Visual Studio Add-in...中间全TMD的英文,我就省略...QT版本不对,需要修改QT版本. 问题原因:占时不明,因为我是开发Del ...

  9. 【Qt】Qt环境搭建(Visual Studio)【转】

    简述 经常有人问我编写Qt程序时使用什么IDE,其实这个真的很难回答(各有所长),只能说看个人爱好了,因为我两个都用,而且两个都很喜欢(比较多情吧O(∩_∩)O~)! 下面将进行Qt Creator与 ...

随机推荐

  1. wpf DoEvents

    原文:wpf DoEvents 如果在执行一段卡UI的代码,这时如何让UI响应.如果存在代码需要获得依赖属性,那么代码就需要在UI线程执行,但是这时就会卡UI,为了让UI响应,所以就需要使用DoEve ...

  2. linux下仅仅有rman备份集的异机不同文件夹恢复

    昨天在客户那里做了一次rman异机的恢复,把生产库弄一份给測试库用,总库大概80G,总共花费了2个小时,当时客户的环境是windows 11.2.0.3,今天早晨在linux下又一次測试了一下,记录下 ...

  3. C++中的类与对象模型

    一,C/C++内存模型 1.内存模型分类 栈区:由编译器自动分配和释放,用来存放函数的参数,局部变量.存放在栈中的数据只在当前函数及下一层函数中有效,函数一旦结束,这些数据就被释放了. 堆区:由程序员 ...

  4. HDU 1867 A + B for you again KMP解决问题的方法

    这是一个典型问题KMP申请书. 结果求增加两个字符串.该法的总和是相同的前缀和后缀也是字符串的字符串,您将可以合并本节. 但是,这个问题是不是问题非常明确的含义,因为不是太清楚,外观这两个字符串的顺序 ...

  5. silverlight,WPF动画终极攻略之迟来的第三章 动画整合篇(Blend 4开发)

    原文:silverlight,WPF动画终极攻略之迟来的第三章 动画整合篇(Blend 4开发) 有个问题想请教下大家,我仿了腾讯的SL版QQ,相似度95%以上.我想写成教程教大家怎么开发出来,会不会 ...

  6. SICP 锻炼 (1.40)解决摘要

    SICP 锻炼1.40 是一个休闲的工作非常easy,但它看起来很复杂,单的一道题. 题目原题例如以下: 请定义一个过程cubic, 它和newtons-method过程一起使用在以下形式的表达式里: ...

  7. It's about trust

    所有问题, 最后,它归结为:信任. 你能相信别人? 我不是Low esteem.相反,我有信心.问题是.我有一个别人缺乏信任的. Daria家长们说,伪君子:我们必须相信你. Daria马上问:然后, ...

  8. android 随着认识的去除率EditText(它配备了防抖效果)

    Android它没有提供的类似至ios自带的输入框效果清晰(ios简单地只加属性可实现).因此,Android其中 我们要如何实现就需要这种效果用自己的定义的控件实现. 思路:能够使用一个Linear ...

  9. springboot 集成oauth2

    未实现.首先实现spring security. 1. 关于oauth2 隐隐觉得集成oauth2,用好它是一个不太简单的事儿,需要对oauth2了解一番. oauth2比较好的参考,都是别人原创文章 ...

  10. MSRA专访摘要

    前段时间有幸参加微软亚洲研究院之旅,顺便投简历,没想到在两次访谈迎来,并且是连续 的两次被拒绝.严重的刺激到了我.导致我疯狂的复习刷Offer.如今最终算是告于段落.如今也最终有空沉下心来总结 总结近 ...