How to Compile Qt with Visual Studio 2010

Source: Internet
Author: User
Tags install perl visual studio 2010



This post was a step-by-step guide in how to compile Qt 4.x.x with MSVC 2010.



Although we use Qt 4.7.1 as a example (for historical reasons), can also find suggestions on building newer versions of Qt by MSVC-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 is instructions on what to build Qt 5 for x64 platform contributed by Vincenzo Mercu Ri.






Updates


December,. Vincenzo Mercuri shared instructions for building Qt 5.0.0Inch x64Configuration.





December,. Vincenzo Mercuri informed that he has compiled Qt 4.8.4-x64 by the. Also He GKFX instructions for building Qt with Intel C + + Compiler into static library.



November 4: As reported by Mike Pelton, Whatnick and Borislav Stanimirov, & 64bit versions of Qt 4.8.3has been successfully compiled by the This guide, by both Visual Studio &. Be aware this Qt might not being adjusted yet for Windows 8 (as reported here).



June 4: As reported by Wenqing, Qt 4.8.2 have been successfully compiled by the This guide.



April 5: As reported by Snouty, 32bit version of Qt 4.8.1 have been successfully compiled by this G Uide.



December: As reported by Evon, 64bit version of Qt 4.8.0 have been successfully compiled by this Guide. To does 64bit compilation, please use the inVisual Studio x64 Win64 Command Prompt (2010)step 8. Also use the andjom 1.06don ' t forget to install Service Pack 1 for Visual Studio.



September: Qt 4.7.4 have been successfully compiled by this guide.



August: Inorder to build the Qt for- bits just use inVisual Studio x64 Win64 Command Prompt (2010)step 8. Also Install Service Pack 1 for Visual Studio Beforehand–it fixes few bugs related to x64 compilation.



July: qt 4.7.3 and qt 4.8 (Beta) have been successfully compiled by the This guide. Just Replace version number where applicable.



Build Instructions


  1. Visual C + + contains all necessary SDKs for Qt compilation. However if you plan to use QT with Phonon your need to install DirectX SDK first.

  2. Install Perl If you is 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 to theqt-everywhere-opensource-src-4.7.1directory where you intend to install Qt. It isC:\Qt\4.7.1.

  5. Set Up Environmental variables

  6. QTDIR=C:\Qt\4.7.1

  7. QMAKESPEC=win32-msvc2010

  8. UpdatePATHvariable to include%QTDIR%\bin

  9. Download the latest version of Jom.

  10. Extract jom files toC:\Qt\jomfolder

  11. Start Visual Studio Command Prompt:

  12. Start > Programs > Microsoft Visual Studio 2010 > Visual Studio Tools > Visual Studio Command Prompt.

  13. Run following commands in it (every. A different command:type it then pressEnter):

  14. cd c:\Qt\4.7.1

  15. configure -debug-and-release -opensource -platform win32-msvc2010

  16. ..\jom\jom.exe -j N



Where is number of theNCPU 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 menuQt > Qt Options > Qt Versions > Add



Usually compilation takes about ten hours, but thanks to Jom and Intel SSD Drive it took only 2 hours + minutes on my Mach INE (Windows 7, 64bits)


Remarks


* Jom isnmakereplacement 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 forN.



** Do not forget to use/dthe switch if you want the change drive in command prompt, e.g:cd /d d:. Usualcd d:does not work anymore–a little "surprise" from Microsoft.


Contributions


* As Evon pointed in comments, the Qt folder has a 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 command in step 10:



..\jom\jom.exe clean



Note that PDB files would be deleted too (the files is rarely needed, only for debugging of Qt itself).



** Rob provided his compilation script based on withnmakemulti-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 2010


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.