简体   繁体   English

为 msvc2015 构建 QT - 并获得工作项目?

[英]Building QT for msvc2015 - and get working projects?

There already is a quite related question (rq) here, but it is not specialized enough and my reputation is not high enough to ask for more advice in the comments ... yet, time is running and I've got to get somewhere.这里已经有一个非常相关的问题 (rq) ,但它不够专业,而且我的声誉不够高,无法在评论中寻求更多建议......然而,时间在流逝,我必须有所作为。 Once the original question is answered, this one can and should be deleted.一旦原始问题得到回答,这个问题就可以而且应该被删除。

What I want: Working in Visual Studio 2015, using the qt-library.我想要什么:在 Visual Studio 2015 中工作,使用 qt-library。 That's it.就是这样。

What I did:我做了什么:

  • Install vs2015, works安装vs2015,有效
  • Download the qt5.5.0 source, built it following the (rq) instruction using jom (nmake worked the same, just was slower)下载 qt5.5.0 源代码,使用jom按照(rq)指令构建它(nmake 工作相同,只是速度较慢)
  • Install the qt package extension for vs2015, also following (rq)安装 vs2015 的 qt 包扩展,也遵循(rq)

The first error: The building-process didn't create any mkspecs, so i wasn't able to set the directory in the QT-options in visual studio: "This QT version uses an unsupported makefile generator (used:, supported: MSVN.NET, MSBUILD)"第一个错误:构建过程没有创建任何 mkspecs,所以我无法在 Visual Studio 的 QT 选项中设置目录:“这个 QT 版本使用了不受支持的 makefile 生成器(使用:,支持:MSVN .NET、MSBUILD)”

  • I tried to hack that by replacing it with the mkspec-folder of an installed version to I was able to select the qtbase-folder in the Qt Options.我试图通过用已安装版本的 mkspec 文件夹替换它来破解它,以便我能够在 Qt 选项中选择 qtbase 文件夹。
  • Played around with the library-directories, the include-directories and the additional-dependencies of the VS-Project.使用库目录、包含目录和 VS 项目的附加依赖项。 No matter what I did, the include-files where not found.无论我做什么,都找不到包含文件。

As this didn't work out, I installed qt 5.5.0 mingw492_32 with the installer.由于这不起作用,我使用安装程序安装了 qt 5.5.0 mingw492_32。 Using that I was able to create a new project with the QTCreator.使用它,我能够使用 QTCreator 创建一个新项目。 It compiled in the QTCreator.它在 QTCreator 中编译。 After that I executed之后我执行了

qmake -platform win32-msvc2015 -tp vs

to convert the project into a Visual-Studio-project, while qmake was the executable from the previously BUILT version, not the installed one, the include-files where still not found in visual studio.将项目转换为 Visual-Studio 项目,而 qmake 是先前 BUILT 版本的可执行文件,而不是已安装的版本,包含文件在 Visual Studio 中仍未找到。

What am I doing wrong?我究竟做错了什么? The library-directories, the include-directories and the additional-dependencies look fine to me in the converted project.在转换后的项目中,库目录、包含目录和附加依赖项在我看来很好。


EDIT 1: I followed the walkthrough and everything built successfully.编辑 1:我遵循了演练,一切都成功构建。 Yet, the mkspecs-folder is still empty.然而,mkspecs 文件夹仍然是空的。 Creating a Qt-Widget-application with the Qt Creator endts up in a crashing app (no changes were made to the default code):使用 Qt Creator 创建 Qt-Widget 应用程序最终导致应用程序崩溃(未对默认代码进行任何更改):

Second Chance Assertion Failed: File minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp, Line 980

Calling打电话

qmake -platform win32-msvc2015 -tp vs

also isn't successfull:也没有成功:

qmake -platform win32-msvc2015 -tp vs
WARNING: Unable to generate output for: D:/_Daten/_Studium/Bachelor-Thesis/Visual-Studio/VISAR-FSA/GuiTest/Makefile.Debug [TEMPLATE vsapp]
WARNING: Unable to generate output for: D:/_Daten/_Studium/Bachelor-Thesis/Visual-Studio/VISAR-FSA/GuiTest/Makefile.Release [TEMPLATE vsapp]

EDIT 2:编辑2:

Concerning the mkspecs: Turns out I had to call both:关于 mkspecs:原来我不得不打电话给两个:

jom -j 8
jom install

Now all mkspecs are created.现在所有 mkspec 都已创建。 The official documentation made me think that the second one only was an option for the build when a destination path was set.官方文档让我认为第二个只是在设置目标路径时构建的一个选项。 Yet, a freshly created Qt Widget Application in Qt Creator, with the built and installed QT-version and the correct compiler, still won't compile.然而,在 Qt Creator 中新创建的 Qt Widget 应用程序,带有构建和安装的 QT 版本和正确的编译器,仍然无法编译。 A LNK2019 occures in [qtmain.lib(qtmain_win.obj)], telling me that there is a link to a symbol "__imp__CommandLineToArgvW@8" in function "_WinMain@16", that was not resolved. [qtmain.lib(qtmain_win.obj)] 中出现 LNK2019,告诉我在函数“_WinMain@16”中存在指向符号“__imp__CommandLineToArgvW@8”的链接,该链接未解决。

I have Qt built for VS2015 as well as VS2013 and for 5.50 onwards it shouldn't need anything particularly special to get it to build successfully.我已经为 VS2015 和 VS2013 构建了 Qt,并且对于 5.50 以后的版本,它不需要任何特别的东西就可以成功构建。 I tend to use a cut down version of the Walkthrough that @jafar's mentions (and also closer to the method in the official docs ')我倾向于使用@jafar 提到的演练的精简版(也更接近官方文档中的方法)

  • Clone the qt5 repository or unzip the source克隆 qt5 存储库或解压缩源
  • Start a command prompt.启动命令提示符。 IMPORTANT : create the correct 'VS2015 x86 or x64' prompt重要提示:创建正确的“VS2015 x86 或 x64”提示
  • DON'T edit the msvc-desktop.conf as mentioned in the Walkthrough.不要像演练中提到的那样编辑msvc-desktop.conf (Qt can't be built with the /MT flag) (Qt 不能用 /MT 标志构建)
  • Run configure:运行配置:

    configure -debug-and-release -opensource -platform win32-msvc2015 -opengl desktop -nomake examples -nomake tests配置 -debug-and-release -opensource -platform win32-msvc2015 -opengl desktop -nomake 示例 -nomake 测试

  • Build with jom -j 8 (I find you get diminishing returns beyond that) or nmake .使用jom -j 8 (我发现你的收益递减)或nmake构建。 If you omit the examples and tests I can build the whole of qtbase in about 10-15 minutes如果省略示例和测试,我可以在大约 10-15 分钟内构建整个 qtbase

  • Run jom install or nmake install运行jom installnmake install

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM