Create Qt5 with Visual Studio 2012 / Visual Studio 2013 and Integrate with the IDE

How do you get Qt5 to download and integrate with Visual Studio 2012? What are some of the problems you will encounter, and how do you solve these problems?

UPDATE re. Visual studio 2013

Success is also reported with Visual Studio 2013, and notes are retained for VS 2013.

Also note that the focus of the question is highly dependent on building Qt with Visual Studio. There are also notes on integration with the Visual Studio IDE

+49
c ++ visual-studio-2013 qt5 visual-studio-2012 directx-11
Apr 05 '13 at 5:53 on
source share
5 answers

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.

+77
Apr 09 '13 at 4:19
source share

I was able to successfully integrate Qt 5.0.2 with Visual Studio 2012 in Windows 7 based on the excellent Dan Nissenbaum post above (thanks Dan!) And this qt-project link . Since I took a few steps a little differently, I thought it would be wise to post it here:

The sequence below should be performed in the exact specified order:

0 - Uninstall Avast (if you have one installed) to avoid build errors. Due to an Avast error, deactivation will not work;

1 - install Git (> = 1.6.x);

2 - Install Python (> = 2.6.x). [Python.org];

3 - Install Perl (> = 5.14). [Activestate.com];

4 - Install Ruby. [Rubyinstaller.org];

5 - Open a regular Windows 7 command prompt (do not use the VSM012 Developer Command Prompt);

6 - Select any directory that you want for qt5, as there are NO SPACES MUST for the selected path. I decided to use the path "C: \ qt5";

7 - In the normal Windows 7 command prompt (in my case, asking "C: \ qt5>"), type:

 git clone git://gitorious.org/qt/qt5.git qt5 

8 - Check out the stable version:

 cd qt5 git checkout stable 

9 - You will probably receive a message confirming that this version is already stable. Close the command line;

10 - Open the Visual Studio Developer Console (All Programs> Visual Studio 2012> Visual Studio Tools> Developer Command Prompt for VS2012) and change the current directory to the one you selected ("C: \ qt5" in my example);

11 - Download the Qt submodules ignoring webkit (a common source of build errors ...):

 perl .\init-repository --no-webkit 

12 - Now enter this huge command to properly configure your build:

 configure -developer-build -opensource -nomake examples -nomake tests -nomake demos -debug-and-release -c++11 -mp -nomake webkit -confirm-license 

13 - Then make sure the qlalr module will NOT . To do this, open Windows Explorer and navigate to the Qt directory of your choice ("C: \ qt5" in my example) and check if the qlalr folder exists. If so, delete it;

14 - Build time ... Possible build errors will come from secondary modules (such as webkit), which do not affect the basic functionality of Qt (webkit itself should not be a problem, since we previously set the configuration not to build it). Then we can ignore them and also support assembly on independent modules:

 nmake /I /K 

15 - To complete the integration, follow step 3 of Dan Nissenbaum's post above ("Step 3: Integrating Qt5 with Visual Studio 2012").

+9
May 14 '13 at
source share

I just want to mention that there is a preliminary version of Qt 5.2 for Visual Studio 2012, available at http://qt-project.org/downloads . Therefore, if you have no particular interest in building Qt 5 from sources, you can also use prebuild binaries.

There are also several pre-compiled (x64) binaries for different versions of the compiler available on the Tver-Soft website .

+6
Dec 16 '13 at 17:49
source share

Finally, I was able to compile QT 5.1 (git) with QWebKit on Windows 8 x64 using Visual Studio 2012 and decided that I shared my experience with those who had problems.

1 2, . 3, SmartGit , Qt5. , (, https://qt.gitorious.org/qt/qt3d/ ), , .

ICU 32- Qt5 VS2012 Qt5; Webkit , ICU.

http://download.icu-project.org/files/icu4c/51.2/icu4c-51_2-src.zip

 #define U_CHARSET_IS_UTF8 1 

% ICU%\source\common\unicode\platform.h, % ICU% - ICU.

% ICU%\source\allinone\allinone.sln Visual Studio 2012 . % ICU%\bin .

 set PATH=%ICU%\bin64;%PATH% 

QT

 configure -platform win32-msvc2012 -opengl desktop -opensource -debug-and-release -I %ICU%\include -L %ICU%\icu\lib64 -mp -qt-freetype -icu 

, , , nmake make ( DerivedSources, Makefile.JavaScriptCore.DerivedSources Makefile. WebCore.DerivedSources))

 (set PATH=<stuff>;%PATH%) && .... 

PATH nmake && & && .

  (set PATH=<stuff>;%PATH%) && perl -ne "print $1" css\CSSPropertyNames.in ... 

 perl -ne "print $1" css\CSSPropertyNames.in ... 

, win_flex.exe( win-flex.exe) flex. flex.exe, ( , , ).

, QWebKit , , .

- Update -

. ( PATH =...;% PATH:) = ^)%) Windows script, Qt5 nmake? ( http://qt-project.org/forums/viewthread/20605 ), Makefile , jsom nmake ( win-flex.exe)

+4
Aug 16 '13 at 0:47
source share

compile Qt 5.5 with visual studio 2015:

1- modefier configure.bat in the qtbase directory so that it can generate configure.exe (only the first 18 lines)

  @echo off set QTSRC=%~dp0 set QTDIR=%CD% rem if not exist %QTSRC%.gitignore goto sconf echo Please wait while bootstrapping configure ... for %%C in (cl.exe icl.exe g++.exe perl.exe) do set %%C=%%~$PATH:C rem if "%perl.exe%" == "" ( rem echo Perl not found in PATH. Aborting. >&2 rem exit /b 1 rem ) if not exist mkspecs ( md mkspecs if errorlevel 1 goto exit ) rem perl %QTSRC%bin\syncqt.pl -minimal -module QtCore -outdir "%QTDIR%" %QTSRC% rem if errorlevel 1 goto exit 

2- configure -opensource -confirm-license -mp -nomake examples -nomake tests -release -c++11 -no-warnings-are-errors -platform win32-msvc2015 -no-ltcg

3- nmake

+2
Sep 23 '15 at 13:51
source share



All Articles