【问题标题】:Building Qt - NMAKE : fatal error U1077: 'cd' : return code '0x2'构建 Qt - NMAKE:致命错误 U1077:“cd”:返回代码“0x2”
【发布时间】:2016-01-12 14:06:55
【问题描述】:

我正在尝试使用 msvc2015 构建带有静态链接的 Qt5.5,但我遇到了以下错误(实际上有很多但我只列出了一些,它们都是一样的) :

K:\Archivos de programa\Microsoft Visual Studio 14.0\VC\INCLUDE\cstdint(50): error C2873: 'uint_fast64_t': symbol cannot be used in a using-declaration
K:\Archivos de programa\Microsoft Visual Studio 14.0\VC\INCLUDE\cstdint(52): error C2039: 'intmax_t': is not a member of '`global namespace''
K:\Archivos de programa\Microsoft Visual Studio 14.0\VC\INCLUDE\cstdint(52): error C2873: 'intmax_t': symbol cannot be used in a using-declaration
K:\Archivos de programa\Microsoft Visual Studio 14.0\VC\INCLUDE\cstdint(53): error C2039: 'uintmax_t': is not a member of '`global namespace''
K:\Archivos de programa\Microsoft Visual Studio 14.0\VC\INCLUDE\cstdint(53): error C2873: 'uintmax_t': symbol cannot be used in a using-declaration
NMAKE : fatal error U1077: '"K:\Archivos de programa\Microsoft Visual Studio 14.0\VC\BIN\cl.EXE"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"K:\Archivos de programa\Microsoft Visual Studio 14.0\VC\BIN\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.

要配置编译,我使用以下命令:

configure.bat -confirm-license -static -release -prefix "K:\Qt\msvc2015_static" -platform win32-msvc2015 -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -opengl desktop -qt-sql-sqlite -qt-sql-odbc -opensource -make libs -nomake tools -nomake examples -nomake tests

有人知道发生了什么吗?

【问题讨论】:

    标签: c++ visual-studio qt nmake


    【解决方案1】:

    这个确切的错误已经在 Qt 论坛的this thread 中讨论过了。它链接到一个非官方的补丁,可以找到here

    为方便日后参考,补丁内容如下:

    diff --git a/src/3rdparty/clucene/src/CLucene/StdHeader.h b/src/3rdparty/clucene/src/CLucene/StdHeader.h
    index 224d400..50adbf6 100644
    --- a/src/3rdparty/clucene/src/CLucene/StdHeader.h
    +++ b/src/3rdparty/clucene/src/CLucene/StdHeader.h
    @@ -123,6 +123,9 @@ extern int _lucene_counter_break; //can set a watch on this
     #endif
    
     #if !defined(LUCENE_DISABLE_HASHING) && defined(_CL_HAVE_HASH_MAP) && defined(_CL_HAVE_HASH_SET)
    +   #if (defined(_MSC_VER) && (_MSC_VER >= 1900))
    +   #define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
    +   #endif
        //hashing is all or nothing!
        #include <hash_map>
        #include <hash_set>
    diff --git a/src/3rdparty/clucene/src/CLucene/util/VoidMap.h b/src/3rdparty/clucene/src/CLucene/util/VoidMap.h
    index 1153a01..b37465a 100644
    --- a/src/3rdparty/clucene/src/CLucene/util/VoidMap.h
    +++ b/src/3rdparty/clucene/src/CLucene/util/VoidMap.h
    @@ -217,17 +217,28 @@ public:
    
     //A collection that contains no duplicates
     //does not guarantee that the order will remain constant over time
    +// MSVC2015: https://codereview.qt-project.org/#/c/110682/3//ALL,unified
     template<typename _kt, typename _vt, 
        typename _Compare,
        typename _KeyDeletor=CL_NS(util)::Deletor::Dummy,
        typename _ValueDeletor=CL_NS(util)::Deletor::Dummy>
     class CLSet:public __CLMap<_kt,_vt,
    +#if (defined(_MSC_VER) && (_MSC_VER >= 1900))
    +   CL_NS_STD(map)<_kt,_vt>,
    +#else
        CL_NS_STD(map)<_kt,_vt, _Compare>,
    +#endif
        _KeyDeletor,_ValueDeletor>
     {
    +#if (defined(_MSC_VER) && (_MSC_VER >= 1900))
    +   typedef typename CL_NS_STD(map)<_kt,_vt> _base;
    +   typedef __CLMap<_kt, _vt, CL_NS_STD(map)<_kt,_vt>,
    +       _KeyDeletor,_ValueDeletor> _this;
    +#else
        typedef typename CL_NS_STD(map)<_kt,_vt,_Compare> _base;
        typedef __CLMap<_kt, _vt, CL_NS_STD(map)<_kt,_vt, _Compare>,
            _KeyDeletor,_ValueDeletor> _this;
    +#endif
     public:
        CLSet ( const bool deleteKey=false, const bool deleteValue=false )
        {
    diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ArgList.h b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ArgList.h
    index 8e1fdbe..79511ef 100644
    --- a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ArgList.h
    +++ b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ArgList.h
    @@ -172,7 +172,10 @@ namespace JSC {
             void operator delete[](void*);
    
             void* operator new(size_t, void*);
    +// FIXME: strange magic
    +#if !(defined(_MSC_VER) && (_MSC_VER >= 1900))
             void operator delete(void*, size_t);
    +#endif
         };
    
         class ArgList {
    diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/StringExtras.h b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/StringExtras.h
    index b1ec09f..11670e2 100644
    --- a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/StringExtras.h
    +++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/StringExtras.h
    @@ -36,6 +36,7 @@
     #if COMPILER(MSVC)
     // FIXME: why a COMPILER check instead of OS? also, these should be HAVE checks
    
    +#if (_MSC_VER < 1900)
     inline int snprintf(char* buffer, size_t count, const char* format, ...) 
     {
         int result;
    @@ -45,6 +46,7 @@ inline int snprintf(char* buffer, size_t count, const char* format, ...)
         va_end(args);
         return result;
     }
    +#endif
    
     #if COMPILER(MSVC7) || OS(WINCE)
    
    diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/TypeTraits.h b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/TypeTraits.h
    index 7ba487f..790c6a0 100644
    --- a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/TypeTraits.h
    +++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/TypeTraits.h
    @@ -170,8 +170,16 @@ namespace WTF {
    
         // GCC's libstdc++ 20070724 and later supports C++ TR1 type_traits in the std namespace.
         // VC10 (VS2010) and later support C++ TR1 type_traits in the std::tr1 namespace.
    +    // VC14 (VS2015) and later support C++11 type_traits in the std namespace, but old TR1 names
    +    // have been removed. See https://msdn.microsoft.com/en-us/library/vstudio/bb531344(v=vs.140).aspx
    +    // for details.
    +#if (defined(_MSC_VER) && (_MSC_VER >= 1900))
    +    template<typename T> struct HasTrivialConstructor : public std::is_trivially_default_constructible<T> { };
    +    template<typename T> struct HasTrivialDestructor : public std::is_trivially_destructible<T> { };
    +#else
         template<typename T> struct HasTrivialConstructor : public std::tr1::has_trivial_constructor<T> { };
         template<typename T> struct HasTrivialDestructor : public std::tr1::has_trivial_destructor<T> { };
    +#endif
    
     #else
    
    diff --git a/src/3rdparty/javascriptcore/WebKit.pri b/src/3rdparty/javascriptcore/WebKit.pri
    index 9aaaa99..487aad6 100644
    --- a/src/3rdparty/javascriptcore/WebKit.pri
    +++ b/src/3rdparty/javascriptcore/WebKit.pri
    @@ -22,7 +22,7 @@ isEmpty(OUTPUT_DIR) {
    
     DEFINES += BUILDING_QT__=1
     building-libs {
    -    win32-msvc*|win32-icc: INCLUDEPATH += $$PWD/JavaScriptCore/os-win32
    +    win32-msvc200*|win32-msvc2010*|win32-msvc2012*|win32-msvc2013*|win32-icc: INCLUDEPATH += $$PWD/JavaScriptCore/os-win32
     } else {
         CONFIG(QTDIR_build) {
             QT += webkit
    diff --git a/src/3rdparty/webkit/Source/JavaScriptCore/runtime/ArgList.h b/src/3rdparty/webkit/Source/JavaScriptCore/runtime/ArgList.h
    index bb2d2842..627b015 100644
    --- a/src/3rdparty/webkit/Source/JavaScriptCore/runtime/ArgList.h
    +++ b/src/3rdparty/webkit/Source/JavaScriptCore/runtime/ArgList.h
    @@ -174,7 +174,10 @@ namespace JSC {
             void operator delete[](void*);
    
             void* operator new(size_t, void*);
    +// FIXME: strange magic
    +#if !(defined(_MSC_VER) && (_MSC_VER >= 1900))
             void operator delete(void*, size_t);
    +#endif
         };
    
         class ArgList {
    diff --git a/src/3rdparty/webkit/Source/JavaScriptCore/wtf/StringExtras.h b/src/3rdparty/webkit/Source/JavaScriptCore/wtf/StringExtras.h
    index 371e33b..37e0858 100644
    --- a/src/3rdparty/webkit/Source/JavaScriptCore/wtf/StringExtras.h
    +++ b/src/3rdparty/webkit/Source/JavaScriptCore/wtf/StringExtras.h
    @@ -37,6 +37,7 @@
     #if COMPILER(MSVC)
     // FIXME: why a COMPILER check instead of OS? also, these should be HAVE checks
    
    +#if (_MSC_VER < 1900)
     inline int snprintf(char* buffer, size_t count, const char* format, ...) 
     {
         int result;
    @@ -52,6 +53,7 @@ inline int snprintf(char* buffer, size_t count, const char* format, ...)
    
         return result;
     }
    +#endif
    
     inline double wtf_vsnprintf(char* buffer, size_t count, const char* format, va_list args)
     {
    diff --git a/src/3rdparty/webkit/Source/JavaScriptCore/wtf/TypeTraits.h b/src/3rdparty/webkit/Source/JavaScriptCore/wtf/TypeTraits.h
    index 44103cd..7b09980 100644
    --- a/src/3rdparty/webkit/Source/JavaScriptCore/wtf/TypeTraits.h
    +++ b/src/3rdparty/webkit/Source/JavaScriptCore/wtf/TypeTraits.h
    @@ -183,8 +183,16 @@ namespace WTF {
    
         // GCC's libstdc++ 20070724 and later supports C++ TR1 type_traits in the std namespace.
         // VC10 (VS2010) and later support C++ TR1 type_traits in the std::tr1 namespace.
    +    // VC14 (VS2015) and later support C++11 type_traits in the std namespace, but old TR1 names
    +    // have been removed. See https://msdn.microsoft.com/en-us/library/vstudio/bb531344(v=vs.140).aspx
    +    // for details.
    +#if (defined(_MSC_VER) && (_MSC_VER >= 1900))
    +    template<typename T> struct HasTrivialConstructor : public std::is_trivially_default_constructible<T> { };
    +    template<typename T> struct HasTrivialDestructor : public std::is_trivially_destructible<T> { };
    +#else
         template<typename T> struct HasTrivialConstructor : public std::tr1::has_trivial_constructor<T> { };
         template<typename T> struct HasTrivialDestructor : public std::tr1::has_trivial_destructor<T> { };
    +#endif
    
     #else
    
    diff --git a/src/3rdparty/webkit/Source/WebKit.pri b/src/3rdparty/webkit/Source/WebKit.pri
    index 01f88a4..b607444 100644
    --- a/src/3rdparty/webkit/Source/WebKit.pri
    +++ b/src/3rdparty/webkit/Source/WebKit.pri
    @@ -38,7 +38,7 @@ DEPENDPATH += $$OUT_PWD
    
     DEFINES += BUILDING_QT__=1
     building-libs {
    -    win32-msvc*|win32-icc: INCLUDEPATH += $$PWD/JavaScriptCore/os-win32
    +    win32-msvc200*|win32-msvc2010*|win32-msvc2012*|win32-msvc2013*|win32-icc: INCLUDEPATH += $$PWD/JavaScriptCore/os-win32
     } else {
         CONFIG(QTDIR_build) {
             QT += webkit
    

    【讨论】:

    • 补丁未终止(至少缺少右括号),您还有完整版吗?
    • @LaurentCrivello 我从答案中引用的链接中获取了补丁。我还手动应用了更改,因为我想单独查看它们的效果并且效果很好。
    【解决方案2】:

    @Bowdzone 谢谢。这个补丁就像构建 qt4.8.7 的魅力

    我还需要在 C:\repo\qt\4.8.7\qmake\Makefile.win32(第 27 行)中的 msvc2013 选项之后附加“$(QMAKESPEC)”==“win32-msvc2015”,以获取配置命令工作 - 如building qt for msvc2015 guide lines中所述

    顺便说一句,我必须构建 qt4.8.7 作为 3dslicer OSS 包的依赖项。

    p.s 我没有足够的积分来添加评论。这是该补丁对我有用的验证。

    【讨论】:

      【解决方案3】:

      以管理员身份运行命令提示符,我做到了,为我工作!

      【讨论】:

        【解决方案4】:

        发生这种情况是因为您可能有很长的源代码位置路径。所以尽量缩短代码定位的路径。例如,将它们放在驱动器根目录中的短文件夹名称中。

        另见:https://stackoverflow.com/a/14862127/2385309

        【讨论】:

        • 不是,源码的路径是K:\Qt\Qt5。此外,这与您附加的线程不同,我没有“'C:\Program' 未被识别为内部或外部命令、可运行程序或批处理文件”。错误
        • 您能否复制粘贴您的 PATH 和 VISUALDIR 环境变量。此外,您的代码中已经存在其他错误,symbol cannot be used in a using-declaration 也尝试修复这些错误
        • 另外,您是否在构建命令中使用自定义 -arch 指令?
        • 这样的事情总是发生在每个人身上:)
        猜你喜欢
        • 2020-04-04
        • 2011-10-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-11-29
        • 2016-03-15
        • 2012-05-08
        • 1970-01-01
        相关资源
        最近更新 更多