How To Compile Qt with Visual Studio
How To Compile Qt with Visual Studio
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 19, 2012. Vincenzo 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 Pelton, whatnick and Borislav Stanimirov, 32 & 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 Wenqing, Qt 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, 2011: Qt 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 2011: Qt 4.7.3 and Qt 4.8 (beta) has been successfully compiled by this guide. Just replace version number where applicable.
Build instructions
- 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.
- Install Perl if you are going to compile Qt >= 4.8.0
- Download and extract Qt 4.7.1 Source Code. (Qt 4.8.0 or Latest snapshot).
- Copy contents of the folder
qt-everywhere-opensource-src-4.7.1to the directory where you intend to install Qt. In our case this isC:\Qt\4.7.1. - Set up environmental variables
QTDIR=C:\Qt\4.7.1
QMAKESPEC=win32-msvc2010 - Update
PATHvariable to include%QTDIR%\bin - Download the latest version of jom.
- Extract jom files to
C:\Qt\jomfolder - Start Visual Studio 2010 Command Prompt:
Start > Programs > Microsoft Visual Studio 2010 > Visual Studio Tools > Visual Studio Command Prompt. - 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 NWhere
Nis number of CPU cores you want to utilize for Qt compilation. Larger is better. - Download and install Qt Visual Studio Add-in.
- 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的更多相关文章
- 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. ...
- Qt环境搭建(Qt Creator)+Visual Studio
1.http://www.cnblogs.com/ranjiewen/p/5318768.html 简述 经常有人问我编写Qt程序时使用什么IDE,其实这个真的很难回答(各有所长),只能说看个人爱好了 ...
- CMake结合Visual Studio中开发Qt应用程序注意事项
Qt工程管理 个人比较偏爱于使用CMake来管理C++工程,因为只要编写一个CMakeLists.txt文件,就可以在Windows和Mac上生成各自的IDE工程.在Windows上, CMake自然 ...
- Qt Visual Studio Add-in 导出的 .pri 怎么用?
今天咱们介绍一下 Qt Add-in 导出的 pri 文件怎么用. 一般需要导出这个文件, 主要应该是跨平台编译的需求, 所以这个文件里包含的东西会比较少, 咱们看下导出的文件是什么样子的: # ...
- 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 ...
- qt 4.6.2 与visual studio 2005 集成(编译方法,以及中间遇到的问题)
不知不觉在蒂森差不多半个月了,哈哈,时间过得很快,过得很充实,近来研究QT,首先嘛,肯定要学会安装了,这最基础的不会更不用说下面的啦.闲话少说,进正题,基本的安装步骤网上多的是,但参考一个大多数情况是 ...
- Qt环境搭建(Visual Studio)
简述 经常有人问我编写Qt程序时使用什么IDE,其实这个真的很难回答(各有所长),只能说看个人爱好了,因为我两个都用,而且两个都很喜欢(比较多情吧O(∩_∩)O~)! 下面将进行Qt Creator与 ...
- C++问题-Qt Visual Studio Add-in
问题现象:用VS打开其他人的项目提示如下:Qt Visual Studio Add-in...中间全TMD的英文,我就省略...QT版本不对,需要修改QT版本. 问题原因:占时不明,因为我是开发Del ...
- 【Qt】Qt环境搭建(Visual Studio)【转】
简述 经常有人问我编写Qt程序时使用什么IDE,其实这个真的很难回答(各有所长),只能说看个人爱好了,因为我两个都用,而且两个都很喜欢(比较多情吧O(∩_∩)O~)! 下面将进行Qt Creator与 ...
随机推荐
- C#之Linq、where()、FindAll()的区别
原地址 C#之Linq.where().FindAll()的区别 对于实现了IEnumerable接口的类.类型.集合可以使用Linq.Linq的扩展方法where().FindAll()来查询符合谓 ...
- Asp.NetCore程序发布到CentOs(含安装部署netcore)--最佳实践
原文:Asp.NetCore程序发布到CentOs(含安装部署netcore)--最佳实践 环境 本地 win7 服务器:Virtual Box 上的Centos ssh工具: Xshell 文件传输 ...
- listview选中滑动时背景变黑
喵的今天调这个一直以为是背景色的问题,花了好多时间 下面才是解决方法:转自:http://daijun74.iteye.com/blog/1175143 手指在ListView上下滚动时,ListVi ...
- DDD实战6 WebAPI
1.在Products解决方案文件夹下面新建一个项目 .net Core/Asp.net Core Web应用程序 取名Product.WebApi/选择Web Api core2.0版本 不进行身 ...
- 关于iis里面 .net framework 版本的切换
然而,即便这样还是不够的 在iis上浏览网站会报以下错误: 这是什么原因呢?这是因为应用程序池中没有使用asp.net v4.0 网站程序是用v4.0写的,所以我们要用4.0的程序池版本,当前应用程序 ...
- Qt5.4.1在windows7配置Android开发环境(阳光柠檬_)
网上的说法有些时间比较久远,软件更新又快,配置路上总有一些坎坷. 自己亲自尝试了一遍,记录下来. 所需的软件: 1. qt-opensource-windows-x86-android-5.4.1.e ...
- WPF特效-实现弧形旋转轮播图
原文:WPF特效-实现弧形旋转轮播图 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/u013224722/article/details/77004 ...
- Spring综合Struts2
1.1. Spring综合Struts2 1) 该Spring用户手机WEB-INF下一个 2) 把Spring配置文件配置到web.xml中 <!-- 引入Spr ...
- [转]TensorFlow如何进行时序预测
TensorFlow 是一个采用数据流图(data flow graphs),用于数值计算的开源软件库.节点(Nodes)在图中表示数学操作,图中的线(edges)则表示在节点间相互联系的多维数据数组 ...
- css 浏览器兼容性问题解决
一个.!important (功能有限) 随着IE7正确!important支持, !important 方法现在只IE6兼容.(注意措辞.我记得这句话需要推进的位置.) : #example ...