19

At this time (September 2015) there is no official Qt build for Visual Studio 2015. How to build it manually?

trig-ger
  • 1,195
  • 1
  • 11
  • 18

1 Answers1

32

It can be built manually quite easily. The example below is for Qt 4.8.6.

  1. Download Qt 4.8.6 sources: http://download.qt.io/archive/qt/4.8/4.8.6/qt-everywhere-opensource-src-4.8.6.zip and unpack. Let the Qt prefix be c:\Qt-2015\4.8.6\msvc2015. Copy sources inside the downloaded source dir to {prefix dir}.

  2. Apply the patch 02-fix_build_with_msvc2015-45e8f4ee.diff https://drive.google.com/file/d/0Bz6Oefew6XZnOU9ac0hIeG41UVE/view?usp=sharing see post: https://forum.qt.io/topic/56453/compiling-qt4-head-with-msvc-2015-cstdint-errors/5 to get rid of compilation errors (I applied all changes by hand, it's not so long).

  3. Make new win32-msvc2015 spec in mkspecs directory: create win32-msvc2015 directory, copy the contents of win32-msvc2013 dir, edit qmake.conf: set _MSC_VER to 1900 and update all text from 2013 to 2015 where appropriate:

    enter image description here

  4. Edit makefile.win32 file in {prefix dir}/qmake/ directory: find all win32-msvc2013 occurences and add win32-msvc2015 similarly:

    enter image description here

    enter image description here

  5. Now from the Visual Studio 2015 command prompt

    enter image description here

    run (these are the example commands, additional commands may be different depending on the build needs):

    configure -make nmake -platform win32-msvc2015 -prefix c:\Qt-2015\4.8.6\msvc2015 -opensource -confirm-license -opengl desktop -nomake examples -nomake tests

    Option -make nmake is need because configure.exe searches max version vs 2013 of nmake by default, otherwise it uses make.

  6. Then for single core build command

    nmake

    (or jom.exe -jN, where N <= number of CPU cores).

    That's all. This example is without Webkit, examples and demos - for speed. For me it takes ~1.5 hours to build on the single core.

trig-ger
  • 1,195
  • 1
  • 11
  • 18
  • 8
    As a note to apply the diff automatically on Windows using Python: `pip install patch` `python -m patch` Then, navigate to the site-packages directory (eg: C:\Python27\lib\site-packages\ ) and find patch.py copy this file to the qt root directory (eg: C:\qt\qt4.8.7\) then on the command line run: `patch.py 02-fix_build_with_msvc2015-45e8f4ee.diff` You can then delete the diff and patch.py files from the qt directory and compile. – Futuza Jul 19 '16 at 19:32
  • 2
    Additionally, with the latest version of qt4.8.7, they've done the work of setting up a win32-msvc2015, so you can skip steps 3 and 4. – Futuza Jul 19 '16 at 19:47
  • 1
    It is additional information to **trig-ger** answer: You can download last version of QT 4.8 (at the moment it is 4.8.7) from [QT download](https://download.qt.io/official_releases/qt/4.8/). This version has support for VS 2015, so you do not need to do steps **3** and **4** from **trig-ger** answer. – SergV Dec 02 '15 at 10:15
  • For anyone who has problems with patch.py. If you have the wrong diff file (i had the original from the answer, (wicht is for version 4.8.6 i guess), patch.py fails without a errormessage. The diff or version 4.8.7 can be found her: https://fami.codefreak.ru/mirrors/qt/unofficial_builds/qt4.8.7-msvc2015/02-fix_build_with_msvc2015-45e8f4ee.diff (from the post in the answer) – Sebastian Ax Jan 12 '17 at 10:23
  • 2
    Everyone, don't forget `nmake install` after the build. – N. Kudryavtsev May 09 '17 at 17:32
  • 1
    I used following link (with this SO article) to build Qt 4.8.7 with Visual Studio 2017: https://github.com/sandym/qt-patches/tree/master/windows/qt-4.8.7 – KonstantinL May 15 '18 at 11:15