更新 OSX 命令行工具 6.3 后缺少C++标头<__debug>
Missing C++ header <__debug> after updating OSX Command Line Tools 6.3
从App Store更新到命令行工具6.3后,包括内部包含<__debug>的<vector>
或<iterator>
的程序将导致文件未找到错误,如下所示。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>
^
有什么想法可以解决这个问题吗?我不希望指定任何其他C++标志。
谢谢。
PS:OSX 10.10.3上的MacBook pro
更新:
苹果在其开发者论坛上验证了该问题。在命令行工具 6.2 中,包含 __debug 有条件地保护如下,但在 6.3 中没有。
#ifdef _LIBCPP_DEBUG
# include <__debug>
#else
# define _LIBCPP_ASSERT(x, m) ((void)0)
#endif
libcxx人在这里谈论撤掉__debug的守卫。感觉__debug在OSX上永远不会存在。
通过 Apple 的开发者下载页面将命令行工具降级到 6.2。
请小心下载适用于您的 OS X 的正确版本:
-
OS X 10.10
commandlinetoolsosx10.10forxcode6.2.dmg
-
OS X 10.9
commandlinetoolsosx10.9forxcode6.2.dmg
这是有效的,因为包含__debug
在命令行工具 6.2 中是有条件的,但在 6.3 中不是。
#ifdef _LIBCPP_DEBUG
# include <__debug>
#else
# define _LIBCPP_ASSERT(x, m) ((void)0)
#endif
在我看来,这是最安全的方法,因为:
- 您不会损害您的工具链
- 当Apple解决问题时,您可以通过App Store轻松升级
- 如果手动添加文件,则必须稍后将其删除,否则可能会出现更多问题
更新 - 21.04.2015
苹果修复的问题。安装命令行工具 6.3.1 后,一切按预期工作!
临时创建缺少的__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
生成完成后删除临时文件。
sudo rm /Library/Developer/CommandLineTools/usr/include/c++/v1/__debug
警告!!这是一个黑客,使用风险自负!!此解决方法仅作为临时修复,直到 Apple 提供命令行工具的更新。
好的,我们开始:自己创建文件并将以下内容放入其中:
#ifndef _LIBCPP_ASSERT
#define _LIBCPP_ASSERT(...) ((void)0)
#endif
这似乎对我有用,但这肯定不是正确的做法。 确保文件位于正确的位置,/Library/Developer/CommandLineTools/usr/include/c++/v1/__debug
具有正确的所有者/权限。
这现已在命令行工具 6.3.1 中修复,可从 https://developer.apple.com/downloads 获得。 更新应自动显示在您的 App Store 更新中(尽管它标记为 6.3,而不是 6.3.1(。 对于给您带来的不便,我们深表歉意,并非常感谢您报告此问题。
早些时候:在简单的情况下,对我有用的解决方法是设置OS X 10.8或更早版本的最低版本,"-mmacosx-version-min=10.8"。
我遵循了谢里登@Flash建议,让我的CLT再次工作(git,ruby,brew...( - 我使用了"命令行工具(OS X 10.10(用于Xcode 6.3.1"。
- g++ 说函数不存在,即使包含正确的标头
- spdlog标头仅与外部fmt一起使用.spdlog错误:'内部':不是'fmt'
- 在CMake中使用find_package时,是否会显式包含标头
- 错误"Could not find Boost"(缺少:上下文标头)
- 如何在标头中声明(或定义)函数的问题
- 如何避免在仅标头库中C++类/变量重定义
- C++算法标头中,为什么要使用 "!(val < *first)" ?
- C++标头错误 C2238 意外标记";"
- std::initializer_list,大括号初始化和标头
- 在 c++ 中拆分类和标头中的继承,错误
- 如何确定哪个标头调用 c++ 中的另一个标头
- 如何在生成文件中添加多个标头 (HDR) 和对象?
- 我可以在运行时重新定义在 OpenCascade/OCCT 标头中定义的 c++ 静态常量吗?
- GCC,CMake,预编译标头和维护依赖项
- VisualStudio:使用 Suse Enterprise Server 12 SP5 时,不会下载远程库标头
- 一个标头库中的错误
- 可视化 Bazel C++预编译标头实现
- 如何在 CMake 中添加预编译标头用于 Visual Studio 生成器
- 使用 GN 构建预编译标头
- 如何从另一个标头 c++ 调用函数