How To Compile Qt 4.7 with Visual Studio 2010

简介:

FEBRUARY 1, 2011

Usual way of installing Qt for Visual Studio is to download already compiled binaries from Nokia website. However binaries for the latest Visual Studio 2010 are not available (on the moment of the writing).

This post is a step-by-step guide on how to compile Qt 4.7.1(3,4) with MSVC 2010.

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.

  1. Visual C++ 2010 contains all necessary SDKs for Qt compilation. However if you plan to use Qt with Phonon you need to install additional software from Qt for Windows Requirements list.
  2. Download and extract Qt 4.7.1 Source Code. (Or Qt 4.7.3Qt 4.7.4).
  3. 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.
  4. Set up environmental variables
    QTDIR=C:\Qt\4.7.1
    QMAKESPEC=win32-msvc2010
  5. Update PATH variable to include %QTDIR%\bin
  6. Download the latest version of jom.
  7. Extract jom files to C:\Qt\jom folder
  8. Start Visual Studio 2010 Command Prompt:
    Start > Programs > Microsoft Visual Studio 2010 > Visual Studio Tools > Visual Studio Command Prompt.
  9. 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.

  10. Download and install Qt Visual Studio Add-in.
  11. 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 9:

..\jom\jom.exe clean

Note that PDB files will be deleted too.

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


==============================================================================
本文转自被遗忘的博客园博客,原文链接:http://www.cnblogs.com/rollenholt/articles/2254904.html,如需转载请自行联系原作者
相关文章
|
7月前
|
IDE 编译器 开发工具
C/C++ IDE环境 (Qt Creator visual studio等) Cmake工程不显示头文件的解决方案
C/C++ IDE环境 (Qt Creator visual studio等) Cmake工程不显示头文件的解决方案
186 0
|
Web App开发 缓存 Windows
Windows / Visual Studio / Qt 实用快捷键 (持续更新)
Windows 平台,集成开发环境 Visual Studio 和 Qt 的一些使用键盘的便捷操作
276 0
|
7月前
|
Windows
Qt 5.14.2 打造跨平台应用的秘诀:用Visual Studio 2022和Qt 5.14.2轻松创建你的首个QT项目
Qt 5.14.2 打造跨平台应用的秘诀:用Visual Studio 2022和Qt 5.14.2轻松创建你的首个QT项目
566 0
|
IDE 开发工具
Visual Studio下程序开发: 编译QT程序Debug正常,Release出错
Visual Studio下程序开发: 编译QT程序Debug正常,Release出错
1006 0
Visual Studio下程序开发: 编译QT程序Debug正常,Release出错
Visual Studio C++ 配置Qt
Visual Studio C++ 配置Qt
146 0
|
编译器 C++
[✔️]CMake生成的VisualStudio项目,Qt的头文件目录默认添加了编译选项,如何在添加到c++头文件目录
[✔️]CMake生成的VisualStudio项目,Qt的头文件目录默认添加了编译选项,如何在添加到c++头文件目录
157 0
|
IDE 开发工具
QT应用编程: 解决Visual Studio下使用qDebug没有输出、输出中文乱码
QT应用编程: 解决Visual Studio下使用qDebug没有输出、输出中文乱码
1092 0
QT应用编程: 解决Visual Studio下使用qDebug没有输出、输出中文乱码
|
安全 IDE 小程序
QT应用编程: Visual Studio里编写activex控件在网页中运行(dll插件形式)
QT应用编程: Visual Studio里编写activex控件在网页中运行(dll插件形式)
252 0
QT应用编程: Visual Studio里编写activex控件在网页中运行(dll插件形式)
|
编译器 数据库 C++
在Visual Studio高版本中使用Qt4,MSVC 2015/2017编译Qt 4.8.7源码
在Visual Studio高版本中使用Qt4,MSVC 2015/2017编译Qt 4.8.7源码
1080 0
在Visual Studio高版本中使用Qt4,MSVC 2015/2017编译Qt 4.8.7源码
Qt Creator能不能像Visual Studio一样设置“使用多字节字符集”
Qt Creator能不能像Visual Studio一样设置“使用多字节字符集”
702 0