qt - 为 Visual Studio Community 2015 构建 Qt 5.6.0 时出错

标签 qt compiler-errors visual-studio-2015 nmake

我一直在尝试构建用于 Visual Studio 2015 社区的 Qt 5.6.0,但是他们网站和 Qt wiki 上的文档在针对 Visual Studio 构建它时并不是很具体。我也尝试过其他教程来构建它,但没有成功。

我试过的教程如下:
https://wiki.qt.io/Building_Qt_5_from_Git
https://doc.qt.io/qt-5/windows-building.html

这些是我在尝试构建它时采取的步骤:

  1. 将源代码从 git repo 克隆到 D:\Programs\qt5。

  2. 检查了我想要的分支。在本例中为 5.6.0。

  3. 仅克隆了基本模块子集以减少构建时间。

  4. 创建了一个批处理脚本来设置 cmd session 的环境变量并将其放置在 D:\Programs\qt5:

    REM Set up \Microsoft Visual Studio 2015, where <arch> is \c amd64, \c x86, etc.
    CALL "D:\Programs\Visual Studio 2015 Community\VC\vcvarsall.bat" amd64
    SET _ROOT=D:\Programs\qt5
    SET PATH=%_ROOT%\qtbase\bin;%_ROOT%\gnuwin32\bin;%PATH%
    REM Uncomment the below line when using a git checkout of the source repository
    SET PATH=%_ROOT%\qtrepotools\bin;%PATH%
    SET QMAKESPEC=win32-msvc2015
    SET _ROOT=
    REM When compiling with ICU, uncomment the lines below and change <icupath> appropriately:
    REM SET INCLUDE=<icupath>\include;%INCLUDE%
    REM SET LIB=<icupath>\lib;%LIB%
    REM SET PATH=<icupath>\lib;%PATH% 
    

    *尝试删除 SET QMAKESPEC 行,但它不会影响产生的错误。

  5. 打开 VS2015 的开发人员命令提示符并导航到 D:\Programs\qt5。

  6. 运行第 4 个脚本。

  7. 输入配置 Qt5 构建的命令。

    configure -developer-build -opensource -confirm-license -nomake tests -nomake examples -mp -skip qtwebengine -skip qtwebchannel
    

    *有没有办法使用 configure 命令只构建基本模块子集

  8. 输入构建Qt的命令。

    nmake
    

    我在尝试构建它时遇到此错误:


    D:\Programs\qt5>nmake

    Microsoft (R) Program Maintenance Utility Version 14.00.23506.0
    Copyright (C) Microsoft Corporation.  All rights reserved.

            cd qtbase\ && ( if not exist Makefile D:\Programs\qt5\qtbase\bin\qmake D:\Programs\qt5\qtbase\qtbase.pro -o Makefile ) && nmake -f Makefile

    Microsoft (R) Program Maintenance Utility Version 14.00.23506.0
    Copyright (C) Microsoft Corporation.  All rights reserved.

            cd src\ && ( if not exist Makefile D:\Programs\qt5\qtbase\bin\qmake D:\Programs\qt5\qtbase\src\src.pro -o Makefile ) && nmake -f Makefile

    Microsoft (R) Program Maintenance Utility Version 14.00.23506.0
    Copyright (C) Microsoft Corporation.  All rights reserved.

            cd corelib\ && ( if not exist Makefile.qtzlib D:\Programs\qt5\qtbase\bin\qmake D:\Programs\qt5\qtbase\src\corelib\qtzlib.pro -o Makefile.qtzlib ) && nmake -f Makefile.qtzlib

    Microsoft (R) Program Maintenance Utility Version 14.00.23506.0
    Copyright (C) Microsoft Corporation.  All rights reserved.

            nmake -f Makefile.qtzlib.Debug all

    Microsoft (R) Program Maintenance Utility Version 14.00.23506.0
    Copyright (C) Microsoft Corporation.  All rights reserved.

            copy /y ..\..\lib\Qt5Zlibd.dll ..\..\bin
    The system cannot find the file specified.
            nmake -f Makefile.qtzlib.Release all

    Microsoft (R) Program Maintenance Utility Version 14.00.23506.0
    Copyright (C) Microsoft Corporation.  All rights reserved.

            copy /y ..\..\lib\Qt5Zlib.dll ..\..\bin
    The system cannot find the file specified.
            cd tools\bootstrap\ && ( if not exist Makefile D:\Programs\qt5\qtbase\bin\qmake D:\Programs\qt5\qtbase\src\tools\bootstrap\bootstrap.pro -o Makefile ) && nmake -f Makefile

    Microsoft (R) Program Maintenance Utility Version 14.00.23506.0
    Copyright (C) Microsoft Corporation.  All rights reserved.

            nmake -f Makefile.Debug

    Microsoft (R) Program Maintenance Utility Version 14.00.23506.0
    Copyright (C) Microsoft Corporation.  All rights reserved.

            cl -c -nologo -Zc:wchar_t -FS -Zi -MDd -D_HAS_EXCEPTIONS=0 -MP -GR -W3 -w34100 -w34189 -w44996 -WX /Fd..\..\..\lib\Qt5Bootstrapd.pdb -DUNICODE -DWIN32 -DWIN64 -DQT_BOOTSTRAPPED -DQT_LITE_UNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO_CODECS -DQT_NO_DATASTREAM -DQT_NO_LIBRARY -DQT_NO_QOBJECT -DQT_NO_SYSTEMLOCALE -DQT_NO_THREAD -DQT_NO_UNICODETABLES -DQT_NO_USING_NAMESPACE -DQT_NO_DEPRECATED -DQT_NO_TRANSLATION -DQT_CRYPTOGRAPHICHASH_ONLY_SHA1 -DQT_NO_CAST_FROM_ASCII -DQT_BUILD_BOOTSTRAP_LIB -DQT_BUILDING_QT -D_CRT_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x040800 -DQT_NO_EXCEPTIONS -I. -I..\..\3rdparty\zlib -I..\..\..\include -I..\..\..\include\QtCore -I..\..\..\include\QtCore\5.6.1 -I..\..\..\include\QtCore\5.6.1\QtCore -I..\..\..\include\QtXml -I..\..\..\include\QtXml\5.6.1 -I..\..\..\include\QtXml\5.6.1\QtXml -Itmp -I..\..\..\mkspecs\win32-msvc2013 -Fo.obj\debug\ @C:\Users\Justin\AppData\Local\Temp\nm3B49.tmp
    qlatincodec.cpp
    qtextcodec.cpp
    qutfcodec.cpp
    d:\programs\qt5\qtbase\include\qtcore\../../src/corelib/global/qflags.h(52): error C2220: warning treated as error - no 'object' file generated (compiling source file ..\..\corelib\codecs\qlatincodec.cpp)
    d:\programs\qt5\qtbase\include\qtcore\../../src/corelib/global/qflags.h(52): warning C4577: 'noexcept' used with no exception handling mode specified; termination on exception is not guaranteed. Specify /EHsc (compiling source file ..\..\corelib\codecs\qlatincodec.cpp)
    d:\programs\qt5\qtbase\include\qtcore\../../src/corelib/global/qflags.h(52): note: to simplify migration, consider the temporary use of /Wv:18 flag with the version of the compiler with which you used to build without warnings (compiling source file ..\..\corelib\codecs\qlatincodec.cpp)
    d:\programs\qt5\qtbase\include\qtcore\../../src/corelib/global/qflags.h(52): error C2220: warning treated as error - no 'object' file generated (compiling source file ..\..\corelib\codecs\qutfcodec.cpp)
    d:\programs\qt5\qtbase\include\qtcore\../../src/corelib/global/qflags.h(52): warning C4577: 'noexcept' used with no exception handling mode specified; termination on exception is not guaranteed. Specify /EHsc (compiling source file ..\..\corelib\codecs\qutfcodec.cpp)
    d:\programs\qt5\qtbase\include\qtcore\../../src/corelib/global/qflags.h(52): note: to simplify migration, consider the temporary use of /Wv:18 flag with the version of the compiler with which you used to build without warnings (compiling source file ..\..\corelib\codecs\qutfcodec.cpp)
    d:\programs\qt5\qtbase\include\qtcore\../../src/corelib/global/qflags.h(52): error C2220: warning treated as error - no 'object' file generated (compiling source file ..\..\corelib\codecs\qtextcodec.cpp)
    d:\programs\qt5\qtbase\include\qtcore\../../src/corelib/global/qflags.h(52): warning C4577: 'noexcept' used with no exception handling mode specified; termination on exception is not guaranteed. Specify /EHsc (compiling source file ..\..\corelib\codecs\qtextcodec.cpp)
    d:\programs\qt5\qtbase\include\qtcore\../../src/corelib/global/qflags.h(52): note: to simplify migration, consider the temporary use of /Wv:18 flag with the version of the compiler with which you used to build without warnings (compiling source file ..\..\corelib\codecs\qtextcodec.cpp)
    NMAKE : fatal error U1077: '"D:\Programs\Visual Studio 2015 Community\VC\BIN\amd64\cl.EXE"' : return code '0x2'
    Stop.
    NMAKE : fatal error U1077: '"D:\Programs\Visual Studio 2015 Community\VC\BIN\amd64\nmake.EXE"' : return code '0x2'
    Stop.
    NMAKE : fatal error U1077: 'cd' : return code '0x2'
    Stop.
    NMAKE : fatal error U1077: 'cd' : return code '0x2'
    Stop.
    NMAKE : fatal error U1077: 'cd' : return code '0x2'
    Stop.

我曾尝试搜索此错误以找到修复方法,但到目前为止我根本无法获得有关它的太多信息。

非常感谢有关该主题的任何帮助,谢谢。

最佳答案

这是一个手动修复,本身不是解决方案,但如果您查看错误消息,您会看到:

cd tools\bootstrap\ && ( if not exist Makefile...

nmake -f Makefile.Debug....

转到该文件夹​​并打开文件 MakeFile.Debug。在那里你会找到一个名为 CXXFLAGS 的条目。在末尾添加“/EHsc”并保存文件。

然后再次运行 nmake

错误有点令人困惑。第一个

error C2220: warning treated as error - no 'object' file generated

是 Qt 遇到的问题的后续错误。 Visual Studio 2015 有一些导致实际问题的新设计:

warning C4577: 'noexcept' used with no exception handling mode specified

也提到了本地解决方案:

Specify /EHsc

这就是我的修复程序所做的。它只是告诉编译器忽略一些异常或以不同方式处理它们。在这种情况下,问题可能出自抛出异常的 C 函数,但 C++ 包装器不处理它。

更多信息请阅读 /EH documentation .

关于qt - 为 Visual Studio Community 2015 构建 Qt 5.6.0 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36870524/

相关文章:

sql - Oracle中触发器语句的编译器错误

c++ - 宏中模板参数数量错误

c++ - 如何在不创建新配置的情况下对两个不同解决方案使用的一个项目使用不同的#defines

c++ - 为内联函数定义多次,怎么可能?

stored-procedures - ASP.Net MVC(C#)中如何调用和执行存储过程

debugging - 如何在 Visual Studio 2015 asp.net 5 中调试 Typescript?

c++ - 获取选定的菜单项

c++ - 在 IDE 外运行时出现 QNetworkReply::UnknownNetworkError

c++ - 用 go + swig 替换 c++

c++ - 带有数百万个项目的 QListView 使用键盘缓慢