zl程序教程

您现在的位置是:首页 >  工具

当前栏目

How To Compile Qt 4.7 with Visual Studio 2010

QtVisualStudio to with How 2010 compile
2023-09-14 08:59:44 时间

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

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. Download and extract Qt 4.7.1 Source Code. (Or Qt 4.7.3Qt 4.7.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. 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 N

 

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


Qt 3D Studio-02-相互了解、勇于探索 在大学的时候接触到Qt,哪会因为学习C++的时候,学到MFC的时候一点兴趣都没有了,对MFC是一点感觉都没有,那个时候很痛苦呀,这个时候Qt走入了我的世界,从此与Qt结缘,他陪伴周南闯北。
Visual Studio 安装OpenCV及问题总结 1、VS安装OpenCV基本步骤 1)安装Visual Studio 下载网址https://opencv.org/releases.html# 2)安装OpenCV 下载网址https://www.