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.1
to 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
PATH
variable to include%QTDIR%\bin
- Download the latest version of jom.
- Extract jom files to
C:\Qt\jom
folder - 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
N
is 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与 ...
随机推荐
- WPF入门(三)->几何图形之不规则图形(PathGeometry) (2)
原文:WPF入门(三)->几何图形之不规则图形(PathGeometry) (2) 上一节我们介绍了PathGeometry中LineSegment是点与点之间绘制的一条直线,那么我们这一节来看 ...
- AJAX跨域与JSONP的一点实践经验
前几个周,项目中遇到了AJAX跨域的问题,然后找资料解决了. 首先要说明一点,关于AJAX的跨域原理和实践,我的经验还是比较少的,我只是大致看了下网上的资料,结合自己的理解,找到了解决办法,暂时不去仔 ...
- spring boot jar 部署linux服务器
用命令启动spring boot 项目,一旦终端命令窗口关闭,项目也就关闭了,所以我们采用脚本的方式来运行jar 正常命令 java -jar xxx.jar 脚本启动,vim 创建 start.sh ...
- O'Stolz 定理及其应用
1. 基本形式 对于 ⋆∞(分母为无穷大,分子无要求),设两数列 an,bn,满足: bn 严格单调递增: limn→∞bn=∞ 如果有 limn→∞an+1−anbn+1−bn=L(L 为有限实数) ...
- STL关联式容器之set和multiset
一,set和multiset的基础知识 1.set和multiset的基础 set是一个集合容器,其中所包含的元素是唯一的,集合中的元素按照一定的顺序排列,元素插入过程是按照排序规则插入的.所以不能指 ...
- 3 Task中的一些枚举 创建时候的、continue时候的
创建时常用的枚举: None.PreferFairness.LongRunning.AttacthedToParent.DenyChildAttach.HideScheduler AttacthedT ...
- ios7 左右searchbar在设置cancelButton的title属性
经 [searchBarsetShowsCancelButton:YES];设置之后默认是"cancel",想改为中文的 在stackoverflow上參考了非常多方法都没用 这里 ...
- python 教程 第十章、 输入/输出
第十章. 输入/输出 1) 文件 poem = '''Programming is fun use Python!''' f = file('poem.txt', 'w') # open for ...
- img前置显示屏装load图片
只需要设置img的background能够 <img src="" alt="" class="detailImg" > cs ...
- ArcGIS Runtime SDK for WPF 初始化
安装包 管理nuget包 Esri.ArcGISRuntime.WPF 也许还需要 Esri.ArcGISRuntime.Hydrography Esri.ArcGISRuntime.LocalSer ...