This method has been tested to work with Visual Studio 2013. Pre-created binaries using Visual Studio 2012 and 2013 are available here , including the OpenGL versions.
Step 1: Setup
Download and install RapidEE here . RapidEE is a Windows environment variable editor. This is extremely useful for the rest of the process (and just generally).
Install the DirectX 11 SDK. Now it is part of the Windows 8 SDK, so you first need to install the DirectX 10 SDK, which you can get here (but see the Warning in the next sentence). If you have the Visual C ++ 2010 redistributable package installed and you probably did (it automatically installs with VS 2010), follow the steps described here to help install DirectX 10. After installing the DirectX 10 SDK, download and install The Windows 8 SDK here , which contains the DirectX 11 SDK. Yes, it’s a pain, but if you don’t know that you have a DirectX 11 SDK, the Qt build will fail.
Install Python for Windows (I heard 2.6+, working with 3.3) from Python.org or Anaconda Python .
Install Perl for Windows from ActiveState .
Step 2: Build (and Build) Qt5 (yes, which means Git )
Follow the installation guide for Windows on the qt project website.
Summary
To summarize the details from the above link and from the following notes (PLEASE SEE THE FOLLOWING NOTES, if you have any errors, they can be answered):
Uninstall Avast (if you have one installed) to avoid build errors. Yes, it literally means delete . Remove it 100% from your system. Deactivation will not work . See Detailed Notes below.
Note for the first steps : DO NOT use SmartGit for the first git pull, below (unless you really know what you are doing), since the default values ​​for SmartGit will pull everything, and that is not what you want.
Git for Windows must be installed.
Determine where you want to install Qt , and cd into the directory that will contain the new installation from any command prompt window. (Since the process is so fragile and error prone, I personally put it directly in C: but this is probably not necessary).
In the above directory, do:
git clone git://gitorious.org/qt/qt5.git qt5
It is fast. Once you're done, you should be on the “stable” branch, but you can always run git checkout stable after cd ing in the newly created qt5 directory to be sure. Using git checkout 5.4.1 confirmed to work with 64-bit VS2013.
Close the window of the current command prompt window (if it is not a Visual Studio command prompt window) before proceeding to the next step. This is to ensure that you are using the Visual Studio Command Prompt window in the following steps.
Next, run the 32-bit (x86) or 64-bit command line VS Tools (depending on how you build Qt5 as 32-bit or 64-bit). To access this, you must find it in the Start menu - go to Program Files → [Microsoft] Visual Studio 2012/2013 → Visual Studio Tools , and you will see it there with a funny name; The name must include the phrase Native Tools ; The 32-bit version will have x86 in the name, and in the 64-bit version there will be x64 in the name.
cd to the newly created qt5 directory from step above.
At the Visual Studio command prompt, you need to load the remainder of the Qt submodules:
perl ./init-repository --no-webkit
It takes some time to complete this step because it should load a lot, but it is not too scary on a decent connection.
Then download all the remaining ADDITIONAL submodules that the init-repository does not load - SmartGit works well, only from this point on (see comments below).
After the Qt download is complete, the following command prepares the build environment (it should also be executed using the command line [32 | 64] VS Native Tools]:
configure -developer-build -opensource -confirm-license -mp -nomake examples -nomake tests -debug-and-release -c++11 -no-warnings-are-errors -platform win32-msvc2012 .
Notes on this command line: c++11 may not be needed using the VS2012 compiler, but it works with VS2013; -no-warnings-are-errors necessary if you receive errors in the 64-bit automatic assembly ANGLE; -platform automatically installed on win32-msvc2012 , therefore the default 32-bit Qt build is used, and the -platform probably does not need to be provided on the command line (EVEN if you have previous versions of VS installed). For VS2013 use -platform win32-msvc2013 .
It takes a few minutes to complete this step, but it’s not so bad.
Finally, the command to actually build Qt on the system (also run on the VS Native Tools command line) is simple:
nmake
Expect the hours to be completed. If you specified the output folder with -prefix (see Notes below), use nmake install , otherwise it.
NOTES:
General notes
If you are confused from the above documentation, it’s just FYI that the ANGLE library will be used (by default) instead of OpenGL and therefore you had to install DirectX 11 above.
Make sure you use the VS Native Tools Command Prompt command line to run all the commands from the link above (i.e., perl .\init-repository --no-webkit , configure and nmake ). You will use the command line [32 | 64] bit ( x86 or x64 ), depending on whether you build Qt as 32-bit or 64-bit. If you install perl with an open command line (make sure it is in PATH ), you need to restart the command line for perl, which will be recognized as a command.
When you run "init-repository" (from the steps in the link above), this is not clear from the documentation, but you have to do it through perl ; those. perl ./init-repository --no-webkit . However, configure and nmake are invoked directly.
One very useful option for switching to configure is -mp , which forces Qt to build on multiple cores in parallel, significantly speeding up (long) build time.
To specify the output folder, add the -prefix [outfolder] command to the configure command. For example, using -prefix %CD%\output\x64\vc12 would be the appropriate output (sub) folder for the 64-bit build of Visual Studio 2013 (12.0).
Unicode Support (ICU)
If you need Unicode support (via ICU ), pay particular attention to the instructions in the link above. Therefore, the ICU must be built from scratch in VS 2012, since the only preinstalled binaries for the ICU for Windows are for VS 2010. Building in VS 2012 is painless - just find the ICU solution (.sln) in <icuroot> \ icu \ source \ allinone and build both in debug mode and in Release mode (in 32-bit or 64-bit mode, depending on which mode you build Qt in). DO NOT create another bit because the ICU will overwrite the output bin folder). (The Qt build process will correctly host the debug and release assembly of the ICU.) It should be built without errors. Then add the path to <icuroot> \ lib as a string entry in a (possibly) new Windows environment variable called "LIB" (for this you can use Rapid EE to make LIB an "extensible string" in RapidEE, although there is only 1 entry) , and add the path to <icuroot> \ include as a string entry in a (possibly) new Windows environment variable called "INCLUDE". (Note: Adding these paths to the PATH variable will not work.) After you create Qt, you can delete all of the entries you just added. In addition, adding the runtime path to the ICU DLL (<icuroot> \ bin) in the environment PATH or the Qt build process (in particular, when uic.exe run) will provide a misleading and misleading error . Finally, at the configure command line (below), be sure to add -icu as an additional command-line option.
ICU Failure :
Currently, there seems to be a Qt5 build error with the VS2012 compiler WHEN ICU ISABLED. In particular, qtbase\src\corelib\codecs\qtextcodec.cpp Line 688 (Qt5 v5.02) cannot return the codec for the name of the codec "US-ASCII" (NULL codec), which leads to the failure of "lrelease.exe" when trying dereference the codec later (I lost this file / line number, but this is an obvious difference in the NULL codec variable). Unfortunately, this means that, as far as I know, WebKit cannot be built with (at least) 32-bit Qt5 build with VS2012 compiler , because WebKit requires an ICU.
If someone can build Qt5 with a VS2012 compiler with ICU enabled, update this Wiki like this.
ICU Update :
If you have an ICU in your path, Qt will automatically build it. In other words, the -icu flag exists implicitly. However, this causes an error with "lrelease.exe" as described above. So the way around this is to add the -no-icu flag to the configure command
Additional submodules
If you need submodules in addition to the default submodules, you can use SmartGit (or the command line) after the init-repository command completes. SmartGit is perhaps the easiest, because you do not need to copy the path to the command line, but you can directly use the user interface.
WARNING: DO NOT qlalr THE ADDITIONAL qlalr SUBMODULE , as it will not be built in conjunction with the general Qt assembly and is not needed by Qt users, but is used only for internal Qt development.
WARNING: The shell command line followed by perl .\init-repository --no-webkit should be used (NOT SmartGit); these steps will correctly load only the default standard Qt subsets. You should not use SmartGit to clone and download Git files from git://gitorious.org/qt/qt5.git , because SmartGit does not currently handle submodules correctly. Instead, open the standard Windows shell command prompt (using any command line application, not necessarily the VS Tools command line) and (assuming that Git is installed correctly on the system, SmartGit installation may or may not do this automatically; if not, go to Git for Windows and install directly) type git clone git://gitorious.org/qt/qt5.git directly from the command line; maybe follow this with git checkout stable (I'm not sure if this branch is checked by default); then follow the command line perl .\init-repository --no-webkit to pull out the DEFAULT repositories (except for WebKit, for which ICUs and ICUs apparently cannot be built in 32-bit Qt5 with VS2012, see comments).
The following are the steps to download all the necessary Qt source files: 1. Use the Windows command line to run the initial git clone git://gitorious.org/qt/qt5.git ; 2. Run perl .\init-repository --no-webkit from the command line of VS Tools 2012; and then optional 3. Use SmartGit (from the link above) (or the equivalent) to "open an existing project" (select the root folder of Qt5) and make Pull from SmartGit to download any repositories other than the default settings (but do not download qlalr ). , It; you have all the necessary and additional Qt files (including submodules) in your system.
If anyone discovers other optional submodules that cannot be created and / or intended for internal use only (except qlalr ), update this Wiki to indicate them.
In general, the default submodules obtained through perl .\init-repository --no-webkit . If you know or later find out that you are different (not the default) modules, you can always add them later.
Common problems
If at some point you get a message saying that the python command (or something similar) is not recognized, just check that the folder containing python.exe (or the corresponding .exe ) is part of the path variable. If this is not the case, add it (use RapidEE as mentioned above for convenience) and try repeating what you did. If there is one, make sure you restart your command line AFTER adding the command to the path.
It is important to note two other path-related problems (cited in the documentation linked to the link above): "Make sure that the perl executable is in the path to the perl executable provided by msysgit since the latter is outdated"; and "You may not be able to build if sh.exe is in your PATH (for example, due to the installation of Git or msys). This error was indicated by the qt5-srcqtbasebinqmake.exe command: the command was not found and does not exist. in this case, make sure that sh.exe is not in your path. You will have to reconfigure if your installation is already configured.
During the process, you may encounter an error using nmake in the file. If you do, just go to this directory and force create the problem file. Then run the nmake process on Qt5 again.
Specific problems
ATTENTION: you may need to disable antivirus software AND SANDBOXING during the Qt nmake process (and, to be safe, throughout this process). Internally, Qt executes several executable files that can interfere with antivirus programs (sometimes silently). In particular, if you have sandbox software, make sure you turn off the sandbox.
WARNING: AVAST! Sandbox users: Avast Sandbox has an error in which even if you turn off the Avast automatic sandbox, the sandbox will NOT be disabled and it will silently isolate all resource files automatically created by Qt rcc during the Qt build process. The Qt ALWAYS construct fails for any user who has installed Avast autosandbox, EVEN WITH AUTO-SANDBOXING TURNED OFF. ONLY WAY TO STOP THIS ISSUE TO FULLY REMOVE THE AIR! FROM YOUR SYSTEM before building Qt. You can reinstall Avast! after completing the Qt build.
Compiling Qt5 can take a lot of time (hours, even with the -mp multithreading option). Patience.
Step 3: Integrate Qt5 with Visual Studio 2012
Download and install Visual Studio Qt5 addin . It is located in the “Other Downloads” section at the bottom of the page and will not work with Visual Studio Express.
Open Visual Studio 2012 and go to Qt Options (under "Qt5" in the top menu bar).
On the Qt Versions tab, check if there is Qt5. If it’s not, click Add, select the version name (probably a name like 5.xx), and go to the folder containing qmake.exe (usually C:\Qt\qt5\qtbase ).
Close the Qt Options dialog box.
Create a new Visual Studio project. When you see the New Project dialog box, you should see the Qt5 Projects Template option.
As soon as you have a new Qt project, right-click it and select "Convert to project created using QMake." Create a project, then right-click it and select Convert Project to Qt Add-in Project. Run it again, then run it. You should now have a working Qt project.
Add Qt5 to an existing Visual Studio 2012 VC ++ project
This section may or may not work. If you have problems or have additional / better solutions, leave a comment or edit the appropriate step.
Right-click on your project in VS and select "upload project." Right-click on the project again and select "change [project name] .vcxproj". This will open the project file so you can add Qt5 to it.
Go to the global property group and add or change <Keyword> to Qt4VSv1.0.
Reload the project, then right-click and select Convert Project to Qt Add-in Project
Wait for the conversion to complete (it won't take more than a couple of seconds), then select Qt5>Project Settings . Go to the "Modules" tab and check the modules that your project should count on (the core ones are Core , Widgets and GUI ).
Following the steps here , add the $(QTDIR)\include directory.
NOTES:
If you enable windows.h at any time, before doing this, you need #define NOMINMAX to prevent a conflict with qdatetime.h .
Once the above steps are completed, you can make your project suitable for using Qt Creator by choosing Qt5>Create basic .pro file .
END NOTES: If you have a question related to the information contained in this manual, send it as a new question (not an answer here) and an answer or a link to the answer can be added.