使用Visual Studio 2012 / Visual Studio 2013构建Qt5,并与IDE集成 [英] Building Qt5 with Visual Studio 2012 / Visual Studio 2013, and integrating with the IDE

查看:1507
本文介绍了使用Visual Studio 2012 / Visual Studio 2013构建Qt5,并与IDE集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何让Qt5下载并与Visual Studio 2012集成?你会遇到一些问题,你如何解决这些问题?



UPDATE re。 Visual Studio 2013



Visual Studio 2013也会报告成功,并为VS 2013维护注释。



另请注意,问题的焦点强烈地只是使用Visual Studio 建立Qt。还有关于与Visual Studio IDE集成的注意事项

解决方案

此方法经过测试可在Visual Studio 2013上工作。预构建使用Visual Studio 2012和2013的二进制文件可从此处,包括OpenGL版本。



步骤1:安装




  1. 下载并安装RapidEE < a href =http://www.rapidee.com/en/download#winxp>此处。 RapidEE是一个Windows环境变量编辑器。


  2. 安装DirectX 11 SDK。它现在是Windows 8 SDK的一部分,因此您首先必须安装DirectX 10 SDK,您可以获得这里(但在下一句中看到警告)。如果您安装了Visual C ++ 2010 Redistributable Package,并且您可能已经安装了它(它与VS 2010一起自动安装),请按照在这里协助安装DirectX 10。安装DirectX 10 SDK后,请下载并安装Windows 8 SDK 此处,其中包含DirectX 11 SDK。 是的,这是一个痛苦,但除非你知道你有DirectX 11 SDK,Qt构建将失败。


  3. Python Python.org Anaconda Python


  4. ActiveState







第2步:打开(和构建) Qt5 (是,表示Git




  1. 按照

    摘要



    从上述链接和以下注释摘要详细信息(如果您有任何错误,请回答以下问题,他们可能会回答):




    • 卸载Avast(如果已安装),以避免生成错误。是的,字面上意味着卸载。从系统中删除它100%。 将无法使用。请参阅下面的详细注释。


    • 注意第一步:不要将SmartGit用于第一个 git pull,下面(除非你真的知道你在做什么),因为SmartGit的默认值会拉取所有,这不是你想要的。 >

    • 必须安装 Git for Windows


    • 确定要将 Qt 安装到哪个目录,并将 cd 包含任何命令提示符窗口中的新安装。 (因为过程是如此脆弱和容易出错,我个人把它直接放在 C:,但这可能不是必需的)。


    • 从上述目录执行:



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



      这很快。一旦完成,你应该在'stable'分支,但你总是可以在 cd 之后运行 git checkout stable 到新创建的 qt5 目录中,只是为了确保。使用 git checkout 5.4.1 已确认可与64位的VS2013配合使用。


    • 关闭您当前的命令提示符窗口(如果它不是Visual Studio命令提示符窗口),然后继续下一步。这是为了确保您在后续步骤中使用Visual Studio命令提示符窗口。


    • 接下来运行32位(x86) bit VS Tools命令提示符(取决于您是将Qt5构建为32位还是64位)。要访问它,您必须通过开始菜单找到它 - 转到程序文件 - > [Microsoft] Visual Studio 2012/2013 - > Visual Studio Tools ,你会看到它有一个有趣的名字;该名称应包括短语 Native Tools ; 32位版本将在名称中包含 x86 ,64位版本将在名称中包含 x64


    • cd 加入新建的 qt5 目录。


    • 在Visual Studio命令提示符下,必须下载Qt子模块的其余部分:



      perl ./init-repository-no-webkit


      $ b $


    • >然后下载任何剩余的可选子模块 init-repository 不下载 - SmartGit只在这个阶段开始工作良好(见下面的注释)。


    • 一旦Qt的下载完成,以下命令准备构建环境(它也应该使用[32 | 64] VS Native Tools命令提示符)执行:



      configure -developer-build -opensource -confirm-license -mp -nomake示例-nomake tests -debug-and-release -c ++ 11 -



      此命令行上的注意事项:<$ c $ <$ p $ <$ p <$> c ++ 11 选项可能不需要与VS2012编译器,但适用于VS2013;需要 -no-warnings-are-errors 才能防止在64位自动构建ANGLE时出现错误; -platform 会自动设置为 win32-msvc2012 ,因此默认使用32位构建的Qt, -platform可能不需要在命令行提供(即使您安装了先前版本的VS)。对于VS2013,使用 -platform win32-msvc2013



      执行此步骤需要几分钟,


    • 最后,在系统上实际构建Qt的命令(也在VS Native Tools命令提示符中运行)简单地是:



      nmake



      如果您指定了包含 -prefix (见下面的注释)的输出文件夹,那么使用








注意



p>

如果你对上面链接的文档感到困惑,只是一个FYI,ANGLE库将被使用(默认情况下)而不是OpenGL,这就是为什么你必须请安装上面的DirectX 11.



确保您使用VS Native Tools命令提示符从上面的链接运行所有命令(即 perl .\init-repository --no-webkit configure nmake )。您将使用[32 | 64]位命令提示符( x86 x64 ),具体取决于您是否正在构建Qt为32位或64位。如果在命令提示符打开的情况下安装perl(确保它在 PATH 中),您将需要重新启动perl的命令提示符才能被识别为命令。 / p>

运行init-repository(从上面的链接中的步骤)时,文档并不清楚,但必须通过 perl ;即 perl ./init-repository --no-webkit 。然而, configure nmake 命令直接调用。



传递到 configure 的一个非常有用的选项是 -mp ,这会导致Qt在多个内核上构建



要指定输出文件夹,请添加 -prefix [outfolder] configure 命令。例如,使用 -prefix%CD%\output\x64\vc12 将是64位Visual Studio 2013(12.0)的合适输出(子) )build。






Unicode支持(ICU)



如果您希望使用Unicode支持(通过 ICU ),请特别注意链接中提供的说明以上。总之,ICU必须在VS 2012中从头开始构建,因为Windows的唯一预构建的ICU二进制文件是VS 2010.在VS 2012中的构建是无痛的 - 只需将ICU解决方案(.sln)放在< icuroot> \icu \source\allinone,并且在调试和释放模式下(在32位或64位模式下,取决于你正在构建Qt的模式 - 不要内置在其他位,因为ICU将覆盖带二进制文件的输出文件夹)。 (Qt构建过程将正确地定位ICU的调试vs.发布版本。)它应该没有错误地构建。然后,将路径添加到< icuroot> \lib作为字符串条目在(可能)NEW Windows环境变量名为LIB(你可以使用Rapid EE为此;使LIB在RapidEE中是一个可扩展字符串只有一个条目),并且还将路径添加到< icuroot> \include作为一个字符串条目在(可能)NEW Windows环境变量名为INCLUDE。 (注意:将这些路径添加到PATH变量将不起作用。)Qt构建之后,您可以删除刚刚添加的所有这些条目。此外,还需要将到ICU dll(< icuroot> \bin)的运行时路径添加到环境的PATH变量或Qt构建过程中(具体来说,当 uic.exe runs)会给出一个欺骗性和误导性错误 。最后,在 configure 命令行(下面)中,一定要添加 -icu 作为附加的命令行参数。



ICU失败



目前, Qt5与VS2012编译器时ICU启用。具体来说, qtbase \src\corelib\codecs\qtextcodec.cpp 第688行(Qt5 v5.02)无法返回编解码器的名称为US-ASCII (编解码器为NULL),导致lrelease.exe在尝试解除引用编解码器时崩溃(我已经丢失了该文件/行号,但它是一个明显的解引用NULL 编解码器变量)。不幸的是,这意味着,据我所知, WebKit不能用VS2012编译器(至少)的32位构建的Qt5编译,因为WebKit需要ICU。



如果任何人能够使用启用了ICU的VS2012编译器来构建Qt5,请更新此Wiki。



ICU澄清



如果您的路径中有ICU,Qt会自动建立。换句话说,标志 -icu 是隐含的。但是,这导致与上面提到的lrelease.exe的错误。因此,这种方法将添加标志,-no-icu到configure命令






其他子模块



如果您希望子模块添加到默认子模块,您可以使用SmartGit(或命令行)之后完成 init-repository 命令。 SmartGit可能是最简单的,因为你不需要将路径复制到命令行,但可以直接使用用户界面。



请勿下载可选的 qlalr SUBMODULE ,因为它不会与整体Qt版本结合使用,对Qt的用户不是必需的,但仅用于内部Qt开发。



警告:一个shell命令行,后跟 perl。 \\ init-repository --no-webkit ,必须使用(NOT SmartGit);这些步骤将正确地只下载默认的Qt子模块。您必须使用SmartGit从 git://gitorious.org/qt/qt5.git 克隆和下载Git文件,因为SmartGit不会目前正确处理子模块。相反,打开一个标准的Windows shell命令提示符(使用任何命令提示符应用程序,不一定是VS工具命令提示符)和(假设Git已正确安装在系统上; SmartGit安装可能或不会自动执行;没有,请转到 Git for Windows 并直接安装)键入 git clone git://gitorious.org/ qt / qt5.git 直接从命令行;或许可以跟随 git checkout stable (我不知道这个分支是默认检出);然后使用命令行 perl .\init-repository --no-webkit 下拉DEFAULT存储库(WebKit除外,这需要ICU和ICU看起来不能



因此,下载所有必要的Qt源文件的步骤是:
1.使用Windows命令行执行初始 git clone git://gitorious.org/qt/qt5.git ;
2.在VS Tools 2012命令提示符中执行 perl .\init-repository --no-webkit 然后可选择
3.使用SmartGit(从上面的链接)(或等效的)打开现有项目(选择Qt5根文件夹),并执行从SmartGit中下拉任何非默认存储库不要下载 qlalr )。而已;



如果任何人发现无法构建的其他可选子模块和/或您的系统上有所有必要的和可选的Qt文件仅供内部使用(除了 qlalr ),请更新此维基以指定。



一般来说,通过 perl .\init-repository --no-webkit 获得的默认子模块就足够了。






p> 常规问题



如果在某些时候您收到错误消息说无法识别命令python只需检查包含 python.exe (或相应的 .exe )的文件夹是路径变量的一部分。如果不是,添加它(使用RapidEE,如上所述为了方便),并尝试你在做什么。



另外两个与路径相关的问题很重要,请注意(引用的)从与上面的链接相关联的文档):确保perl可执行文件位于由msysgit提供的perl可执行文件之前的路径中,因为后者已过时;和如果sh.exe在您的PATH(例如由于git或msys安装),您可能无法构建这样的错误由qt5-srcqtbasebinqmake.exe:命令未找到和类似的指示。在这种情况下,请确保sh.exe不在您的路径中,如果您的安装已配置,则必须重新配置。



在此过程中,您可能会在文件上使用 nmake 时遇到错误。如果你这样做,只是进入那个目录,并强制构建问题文件。然后再次在Qt5上开始 nmake 过程。






具体问题



警告:您可能需要在Qt期间停用防病毒软件 AND SANDBOXING nmake 过程(为了安全,整个过程)。在内部,Qt执行许多可执行文件,防病毒程序可以干扰(有时默默)。

沙箱:用户:Avast Sandbox有一个错误,即使您禁用了Avast的自动沙箱,沙箱也不会关闭,它会默默沙箱所有资源文件自动创建的Qt的 rcc 程序在Qt的构建过程中。对于已经安装了Avast自动存储功能的用户来说,Qt构建始终会失败,即使自动 - 手动关闭。唯一的方法来完成这个问题是完全卸载AVAST!从建立Qt之前的系统。您可以重新安装Avast!在Qt构建完成后。






Qt5的编译可能需要很长时间多线程选项)。耐心。






第3步:将Qt5与Visual Studio 2012集成




  1. 下载并安装Visual Studio Qt5 addin


  2. 打开Visual Studio 2012,然后点击下一步到 Qt选项(在顶部菜单栏上的Qt5下)。


  3. 版本选项卡,检查Qt5是否已经存在。如果不是,请单击添加,选择版本名称(可能是一个名称,如5.xx),并导航到包含 qmake.exe 的文件夹(通常 C:\Qt\qt5\qtbase )。


  4. 退出Qt选项对话框。 >


  5. 创建一个新的Visual Studio项目。当您看到新建项目对话框时,应该会看到 Qt5项目模板选项。


  6. 有你的新的Qt项目,右键单击它,选择转换为QMake生成的项目。构建项目,然后再次右键单击并选择将项目转换为Qt加载项目。再次构建,然后运行。







将Qt5添加到现有的Visual Studio 2012 VC ++项目



此部分可能适用于或可能不适用。如果您遇到问题或有其他/更好的解决方案,请发表评论或编辑相应的步骤。


  1. 在VS中右键单击您的项目,然后选择卸载项目。再次右键单击项目,然后选择编辑[项目名称] .vcxproj。


  2. 转到全局属性组,添加或更改


  3. 重新加载项目,然后右键单击并选择将项目转换为Qt Add- in project


  4. 等待转换完成(不需要超过几秒钟),然后选择 Qt5> Project设置。转到模块选项卡,并检查您希望您的项目依赖的模块(基本的核心 Widgets

  5. msdn.microsoft.com/en-us/library/73f9s62w.aspx\">在这里,添加目录 $(QTDIR)\include






    注意



    您需要在 windows.h 之前加入 #define NOMINMAX 以防止与 qdatetime.h 的冲突。



    完成上述步骤后, Qt Creator选择 Qt5>创建基本的.pro文件




< hr>

结束注意:如果您有与本指南中包含的信息相关的问题,请将其作为新问题发布(这里不是答案) ,并且可以添加答案或对答案的链接。


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 those problems?

UPDATE re. Visual Studio 2013

Successes are reported with Visual Studio 2013 as well, and the notes are being maintained for VS 2013.

Also note that the focus of the question is strongly on just building Qt with Visual Studio. There are also notes about integrating with the Visual Studio IDE

解决方案

This method is tested to work on Visual Studio 2013. Pre-built binaries using Visual Studio 2012 and 2013 are available here, including OpenGL versions.

Step 1: The Setup

  1. Download and install RapidEE here. RapidEE is a windows environment variables editor. It is extremely useful for the rest of this process (and just in general).

  2. Install the DirectX 11 SDK. It is now part of the Windows 8 SDK, so you first have to install the DirectX 10 SDK, which you can get here (but see warning in next sentence). If you have the Visual C++ 2010 Redistributable Package installed, and you probably do (it is automatically installed along with VS 2010), follow the steps outlined here to assist with the DirectX 10 installation. Once you have the DirectX 10 SDK installed, download and install the Windows 8 SDK here, which contains the DirectX 11 SDK. Yes, this is a pain, but unless you know you have the DirectX 11 SDK, the Qt build will fail.

  3. Install Python for Windows (I've heard 2.6+, working with 3.3) from Python.org or Anaconda Python.

  4. Install Perl for Windows from ActiveState.


Step 2: Gitting (and building) Qt5 (yes, that means Git)

  1. Follow the installation guide for Windows at the qt-project website.

    Summary

    To summarize the details from the above link and from the following notes (PLEASE SEE FOLLOWING NOTES if you have any errors; they might be answered):

    • Uninstall Avast (if you have this installed) to avoid build errors. Yes, that literally means uninstall it. Remove it 100% from your system. Deactivating it 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're doing), as SmartGit's defaults will pull everything, and that's not what you want.

    • Git for Windows must be installed.

    • Decide where you want to put the Qt installation, and cd to the directory that will contain the new installation from any Command Prompt window. (Because the process is so fragile and error-prone, I personally put it directly in C:, but this is likely not necessary).

    • From the above directory, execute:

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

      This is fast. Once complete, you should be on the 'stable' branch, but you can always run git checkout stable after cding into the newly-created qt5 directory, just to be sure. Using git checkout 5.4.1 is confirmed to work with VS2013 64-bit.

    • Close out of your current command prompt window (if it's not a Visual Studio command prompt window) before proceeding to the next step. This is to make sure you're using the Visual Studio command prompt window in the next steps.

    • Next run the 32-bit (x86) or 64-bit VS Tools command prompt (depending on whether you're building Qt5 as 32- or 64-bit). To access this, you must find it through the Start menu - go to Program Files -> [Microsoft] Visual Studio 2012/2013 -> Visual Studio Tools, and you'll see it in there with a funny name; the name should include the phrase Native Tools; the 32-bit version will have x86 in the name and the 64-bit version will have x64 in the name.

    • cd into the newly-created qt5 directory from the step above.

    • From within the Visual Studio command prompt, the remainder of the Qt submodules must be downloaded:

      perl ./init-repository --no-webkit

      It takes kind of a while to execute this step, because it has to download a lot, but it's not too terrible on a decent connection.

    • Then download any remaining OPTIONAL submodules that init-repository does not download - SmartGit works well only starting at this stage (see comments below).

    • Once the download of Qt is complete, the following command prepares the build environment (it should also be executed using the [32|64] VS Native Tools Command Prompt):

      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: the c++11 option might not be necessary with the VS2012 compiler, but works with VS2013; the -no-warnings-are-errors is necessary in case you get errors on a 64-bit automatic build of ANGLE; -platform is automatically set to win32-msvc2012, so by default the 32-bit build of Qt is used, and -platform probably does not need to be supplied at the command line (EVEN if you have previous versions of VS installed). For VS2013, use -platform win32-msvc2013.

      It takes a few minutes to execute this step, but it's not so bad.

    • Finally, the command to actually build Qt on the system (also run within the VS Native Tools Command Prompt) is simply:

      nmake

      Expect to wait hours for the build to complete. If you specified an output folder with -prefix (see notes below), then use nmake install, otherwise that's it.


NOTES:

General Notes

In case you're confused from the above-linked documentation, just an FYI that the ANGLE library will be used (by default) instead of OpenGL, and that's why you had to install DirectX 11, above.

Make sure that you use the VS Native Tools Command Prompt to run all commands from the above link (that is, perl .\init-repository --no-webkit, configure, and nmake). You will use the [32|64] bit command prompt (x86 or x64), depending on whether you are building Qt as 32-bit or 64-bit. If you install perl with the Command Prompt open (make sure it is in the PATH), you will need to restart the Command Prompt for perl to be recognized as a command.

When running "init-repository" (from the steps in the above link), it's not clear from the documentation, but you must execute this via perl; i.e. perl ./init-repository --no-webkit. The configure and nmake commands, however, are called directly.

One very useful option to pass to configure is -mp, which causes Qt to build on multiple cores in parallel, significantly speeding up the (long) build time.

To specify an output folder add the -prefix [outfolder] to the configure command. For example, use -prefix %CD%\output\x64\vc12 would be a suitable output (sub)folder for a 64-bit Visual Studio 2013 (12.0) build.


Unicode Support (ICU)

If you want Unicode support (via ICU), pay special attention to the instructions noted within the link above. In summary, ICU must be built from scratch in VS 2012, as the only prebuilt ICU binaries for Windows are for VS 2010. Building in VS 2012 is painless - simply locate the ICU solution (.sln) in <icuroot>\icu\source\allinone, and build in both Debug and Release mode (either in 32-bit or 64-bit mode, depending on which mode you're building Qt in - DO NOT build in the other bitness, because ICU will overwrite the output folder with the binaries). (The Qt build process will properly locate the debug vs. release build of ICU.) It should build without errors. Then, add the path to <icuroot>\lib as a string entry in a (probably) NEW Windows environment variable called "LIB" (you can use Rapid EE for this; make LIB an "expandable string" in RapidEE even though there's only 1 entry), and also add the path to <icuroot>\include as a string entry in a (probably) NEW Windows environment variable called "INCLUDE". (Note: Adding these paths to the PATH variable will not work.) After Qt is built, you can remove all of these entries you've just added. Also, do add the runtime path to the ICU dll's (<icuroot>\bin) to the environment's PATH variable, or the Qt build process (specifically, when uic.exe runs) will give a deceptive and misleading error. Finally, on the configure command line (below), be sure to add -icu as an additional command-line parameter.

ICU Failure:

Currently, there seems to be a bug building Qt5 with the VS2012 compiler WHEN ICU IS ENABLED. Specifically, qtbase\src\corelib\codecs\qtextcodec.cpp Line 688 (Qt5 v5.02) fails to return a codec for codec name "US-ASCII" (the codec is NULL), causing "lrelease.exe" to crash when trying to dereference the codec later (I have lost track of that file/line number, but it is an obvious dereference of the NULL codec variable). Unfortunately, this means that to my knowledge, WebKit cannot be built with (at least the) 32-bit build of Qt5 with the VS2012 compiler, because WebKit requires ICU.

If anyone is able to build Qt5 with the VS2012 compiler with ICU enabled, please update this Wiki saying so.

ICU Clarification:

If you have ICU in your path, Qt will automatically built it. In other words, the flag "-icu" is there implicitly. However, this causes an error with "lrelease.exe" as mentioned above. So the way around this would be to add the flag, -no-icu to the configure command


Additional Submodules

If you want submodules in addition to the default submodules, you can use SmartGit (or command line) after you complete the init-repository command. SmartGit is perhaps easiest, because you do not need to copy the path to the command line, but can use the user interface directly.

WARNING: DO NOT DOWNLOAD THE OPTIONAL qlalr SUBMODULE, as it will not build in combination with the overall Qt build, and is not necessary for users of Qt, but is only used for internal Qt development.

WARNING: A shell command line, followed by perl .\init-repository --no-webkit, must be used (NOT SmartGit); these steps will properly only download the default Qt submodules. You must not use SmartGit to clone and download the Git files from git://gitorious.org/qt/qt5.git because SmartGit does not currently handle the submodules properly. Instead, open a standard Windows shell command prompt (using any command-prompt application, not necessarily the VS Tools command prompt), and (assuming Git is properly installed on the system; a SmartGit installation might or might not do this automatically; if it does not, go to Git for Windows and install directly) type git clone git://gitorious.org/qt/qt5.git directly from the command line; perhaps follow that with git checkout stable (I'm not sure if this branch is checked out by default); then follow that with the command line perl .\init-repository --no-webkit to pull down the DEFAULT repositories (except WebKit, which requires ICU and ICU seemingly cannot be built in 32-bit Qt5 with VS2012; see comments).

The steps for downloading all necessary Qt source files therefore are: 1. Use a Windows command line to execute the initial git clone git://gitorious.org/qt/qt5.git; 2. Execute perl .\init-repository --no-webkit from within a VS Tools 2012 Command Prompt; and then optionally 3. Use SmartGit (from above link) (or equivalent) to "open an existing project" (choose the Qt5 root folder) and do a Pull from within SmartGit to download any non-default repositories (but do not download qlalr). That's it; you have all necessary and optional Qt files (including submodules) on your system.

If anybody discovers other optional submodules that fail to build and/or are for internal use only (besides qlalr), please update this Wiki to specify them.

In general, the default submodules obtained via perl .\init-repository --no-webkit are sufficient. If you know, or later find out, that you other (non-default) modules, you can always add them later.


General Problems

If at some point you get the error saying that the command "python" (or anything similar) is not recognized, just check that the folder containing python.exe (or the appropriate .exe) is part of the path variable. If it is not, add it (use RapidEE as noted above for convenience) and try what you were doing again. If it is there, make sure you have restarted your command prompt AFTER the addition of the command to the path.

Two other path-related issues are important to note (quoted from the documentation associated with the link above): "Make sure the perl executable is found in the path before the perl executable provided by msysgit, since the latter is outdated"; and "You might not be able to build if sh.exe is in your PATH (for example due to a git or msys installation). Such an error is indicated by qt5-srcqtbasebinqmake.exe: command not found and alike. In this case, make sure that sh.exe is not in your path. You will have to re-configure if your installation is already configured."

During the process, you may encounter an error using nmake on a file. If you do, just go into that directory and force build the problem file. Then begin the nmake process on Qt5 again.


Specific Problems

WARNING: You may need to disable antivirus software AND SANDBOXING during the Qt nmake process (and, to be safe, throughout this entire process). Internally, Qt executes a number of executables that antivirus programs can interfere with (sometimes silently). In particular, if you have any sandboxing software, be SURE to disable sandboxing.

WARNING: AVAST! Sandbox users: Avast Sandbox has a bug in which even when you disable Avast's auto-sandbox, the sandbox will NOT turn off and it will silently sandbox all resource files automatically created by Qt's rcc program during Qt's build process. The Qt build ALWAYS fails for any user who has installed the Avast autosandbox feature, EVEN WITH AUTO-SANDBOXING TURNED OFF. THE ONLY WAY TO OVERCOME THIS ISSUE IS TO COMPLETELY UNINSTALL AVAST! FROM YOUR SYSTEM before building Qt. You can reinstall Avast! after the Qt build is complete.


The compilation of Qt5 can take a long time (hours, even with the -mp multithreading option). Patience.


Step 3: Integrating Qt5 with Visual Studio 2012

  1. Download and install the Visual Studio Qt5 addin. It is in the "Other Downloads" section near the bottom of the page, and will not work with Visual Studio Express.

  2. Open Visual Studio 2012, and go to Qt Options (It's under "Qt5" on the top menu bar).

  3. In the Qt Versions tab, check to see if Qt5 is already there. If it is not, click add, choose a version name (probably a name such as 5.x.x), and navigate to the folder containing qmake.exe (usually C:\Qt\qt5\qtbase).

  4. Exit the Qt Options dialog.

  5. Create a new Visual Studio Project. When you see the New Project dialog, you should see the Qt5 Projects Template option.

  6. Once you have your new Qt Project, right click on it and select "Convert to QMake generated project". Build the project, then right click on it again and select "Convert project to Qt Add-in project". Build again, then run. 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 for you. If you run into problems or have additional/better solutions, please leave a comment or edit the appropriate step.

  1. Right-click on your project in VS, and choose "unload project". Right click on the project again, and select "edit [project name].vcxproj". This opens the project file so you can add Qt5 to it.

  2. Go down to the Global PropertyGroup, and add or change the <Keyword> to Qt4VSv1.0.

  3. Reload the project, then right-click and select "Convert project to Qt Add-in project"

  4. Wait for the conversion to finish (it does not take more than a couple seconds), then choose Qt5>Project Settings. Go to the Modules tab, and check the modules you would like your project to rely on (the basic ones are Core, Widgets, and GUI).

  5. Following the steps here, add the directory $(QTDIR)\include.


    NOTES:

    If at any time you are including windows.h, you need to #define NOMINMAX before doing so to prevent conflict with qdatetime.h.

    Once the above steps are done, you can make your project usable by Qt Creator by selecting Qt5>Create basic .pro file.


ENDING NOTES: If you have a question related to the information contained in this guide, please post it as a new question (not an answer here), and the answer or a link to the answer may get added.

这篇关于使用Visual Studio 2012 / Visual Studio 2013构建Qt5,并与IDE集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆