xcode 更新 OSX 命令行工具 6.3 后缺少 C++ 头文件 <__debug>

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29529455/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 06:56:06  来源:igfitidea点击:

Missing C++ header <__debug> after updating OSX Command Line Tools 6.3

c++xcodemacosstlclang

提问by Farley

After updating to Command Line Tools 6.3 from the App Store, programs including <vector>or <iterator>which internally include <__debug> will cause file not found error as follows. The cpp is nothing interesting but includes in one of the included headers.

从 App Store 更新到命令行工具 6.3 后,包含<vector><iterator>内部包含 <__debug> 的程序将导致文件未找到错误,如下所示。cpp 没什么有趣的,但包含在包含的标题之一中。

c++ -O3 -I/Users/farleylai/Documents/dev/git/ESMS/Optimizer/../StreamIt/src/cluster/headers -L/Users/farleylai/Documents/dev/git/ESMS/Optimizer/../StreamIt/build/binaries/clusterStaticLibrary /Users/farleylai/Documents/dev/git/ESMS/Optimizer/build/StreamIt/FIR/511/512/combined_threads.cpp -o streamit -lcluster -lpthread -lstdc++
In file included from /Users/farleylai/Documents/dev/git/ESMS/Optimizer/build/StreamIt/FIR/511/512/combined_threads.cpp:9:
In file included from /Users/farleylai/Documents/dev/git/ESMS/Optimizer/../StreamIt/src/cluster/headers/node_server.h:22:
In file included from /Users/farleylai/Documents/dev/git/ESMS/Optimizer/../StreamIt/src/cluster/headers/thread_info.h:20:
In file included from /Users/farleylai/Documents/dev/git/ESMS/Optimizer/../StreamIt/src/cluster/headers/connection_info.h:19:
/Users/farleylai/Documents/dev/git/ESMS/Optimizer/../StreamIt/src/cluster/headers/socket_holder.h:43:25: warning: delete called on 'mysocket' that is abstract but has non-virtual destructor
      [-Wdelete-non-virtual-dtor]
    if (!is_mem_socket) delete sock;
                        ^
In file included from /Users/farleylai/Documents/dev/git/ESMS/Optimizer/build/StreamIt/FIR/511/512/combined_threads.cpp:9:
In file included from /Users/farleylai/Documents/dev/git/ESMS/Optimizer/../StreamIt/src/cluster/headers/node_server.h:22:
In file included from /Users/farleylai/Documents/dev/git/ESMS/Optimizer/../StreamIt/src/cluster/headers/thread_info.h:26:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/vector:265:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__bit_reference:15:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/algorithm:641:10: fatal error: '__debug' file not found
#include <__debug>
         ^

Any ideas to fix this? I don't expect to specify any additional C++ flags.

有什么想法可以解决这个问题吗?我不希望指定任何额外的 C++ 标志。

Thanks.

谢谢。

PS: MacBook pro on OSX 10.10.3

PS:OSX 10.10.3 上的 MacBook pro

Updates:

更新:

The issue is verified by Apple on their developer's forum. In Command Line Tools 6.2, the inclusion of __debug is conditionally guarded as follows but not in 6.3.

该问题已由 Apple 在其开发者论坛上验证。在命令行工具 6.2 中,__debug 的包含有条件地保护如下,但在 6.3 中没有。

#ifdef _LIBCPP_DEBUG
#   include <__debug>
#else
#   define _LIBCPP_ASSERT(x, m) ((void)0)
#endif

And libcxx people talked about removing the guards of __debug here. It feels like __debug never exists on OSX.

并且 libcxx 人在这里谈到了移除 __debug 的守卫。感觉 __debug 在 OSX 上从来不存在。

回答by gismo141

Downgrade the Command Line Tools to 6.2via Apple's Developer Download Page.

通过Apple 的开发人员下载页面将命令行工具降级到6.2

Be careful to download the correct version for your OS X:

请小心为您的 OS X 下载正确的版本:

  • OS X 10.10commandlinetoolsosx10.10forxcode6.2.dmg
  • OS X 10.9commandlinetoolsosx10.9forxcode6.2.dmg
  • OS X 10.10commandlinetoolsosx10.10forxcode6.2.dmg
  • OS X 10.9commandlinetoolsosx10.9forxcode6.2.dmg

This works because the inclusion of __debugis conditionally guarded as follows in Command Line Tools 6.2 but not in 6.3.

这是有效的,因为包含__debug在命令行工具 6.2 中有条件地受到保护,如下所示,但在 6.3 中则不然。

#ifdef _LIBCPP_DEBUG
#   include <__debug>
#else
#   define _LIBCPP_ASSERT(x, m) ((void)0)
#endif

In my opinion this is the safest way, because:

在我看来,这是最安全的方法,因为:

  1. You don't compromise your toolchain
  2. You can easily upgrade via the App Store when Apple fixes the issue
  3. If you add a file manually you have to delete it later or more problems could occur
  1. 您不会损害您的工具链
  2. 当 Apple 修复问题时,您可以通过 App Store 轻松升级
  3. 如果您手动添加文件,则必须稍后将其删除,否则可能会出现更多问题

Update - 21.04.2015

更新 - 21.04.2015

Problem fixedby Apple. After installing Command Line Tools 6.3.1everything works as expected!

问题由苹果解决。安装命令行工具6.3.1 后,一切正常!

回答by jwu

Temporarily create the missing __debugfile where _LIBCPP_ASSERTis defined as in Command Line Tools 6.2 for OS X.

临时创建丢失的__debug文件,_LIBCPP_ASSERT在 OS X 的命令行工具 6.2 中定义。

echo '#define _LIBCPP_ASSERT(x, m) ((void)0)' | sudo tee -a /Library/Developer/CommandLineTools/usr/include/c++/v1/__debug > /dev/null

Remove the temporary file after the build finished.

构建完成后删除临时文件。

sudo rm /Library/Developer/CommandLineTools/usr/include/c++/v1/__debug

回答by Daniel Frey

Warning!!! This is a hack, use at your own risk!!!This work-around is only meant as a temporaryfix until Apple provides an update to the command-line tools.

警告!!!这是一个黑客,使用风险自负!!!在Apple 提供命令行工具更新之前,此变通方法仅作为临时修复。

OK, here we go: Create the file yourself and put the following content into it:

好了,开始吧:自己创建文件,放入如下内容:

#ifndef _LIBCPP_ASSERT
#define _LIBCPP_ASSERT(...) ((void)0)
#endif

This seemsto work for me, but it is certainly not the right thing to do. Make sure the file is located at the right place /Library/Developer/CommandLineTools/usr/include/c++/v1/__debugwith the right owner/permissions.

似乎对我有用,但这肯定不是正确的做法。确保文件位于正确的位置/Library/Developer/CommandLineTools/usr/include/c++/v1/__debug并具有正确的所有者/权限。

回答by Flash Sheridan

This is now fixed in Command Line Tools 6.3.1, available from https://developer.apple.com/downloads. The update should appear automatically in your App Store Updates (though it's labelled as 6.3, not 6.3.1). Apologies for the inconvenience, and thanks very much for reporting the issue.

此问题现已在命令行工具 6.3.1 中修复,可从https://developer.apple.com/downloads 获得。该更新应自动出现在您的 App Store 更新中(尽管它被标记为 6.3,而不是 6.3.1)。对给您带来的不便深表歉意,非常感谢您报告此问题。

Earlier: A workaround which worked for me in a simple case was setting a minimum of OS X 10.8 or earlier, with “-mmacosx-version-min=10.8”.

早些时候:在一个简单的情况下对我有用的解决方法是设置最低 OS X 10.8 或更早版本,使用“-mmacosx-version-min=10.8”。

回答by zstolar

I followed @Flash Sheridan advice and got my CLT working again (git, ruby, brew...) - I used "Command Line Tools (OS X 10.10) for Xcode 6.3.1".

我遵循了@Flash Sheridan 的建议,让我的 CLT 再次工作(git、ruby、brew ...) - 我使用了“Xcode 6.3.1 的命令行工具(OS X 10.10)”。