将 OSX 从 12.1 升级到 12.2.1 破坏了我的开发环境
upgrading OSX from 12.1 to 12.2.1 broke my development environment
我在从 12.1 轻微 OSX 升级到 12.2.1 后编译软件时看到各种错误和警告。
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/unordered_map:411:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__hash_table:18:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:321:9: error: no member named 'signbit' in the global namespace
using ::signbit;
~~^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:322:9: error: no member named 'fpclassify' in the global namespace
using ::fpclassify;
~~^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:323:9: error: no member named 'isfinite' in the global namespace; did you mean 'finite'?
using ::isfinite;
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/unordered_map:411:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__hash_table:18:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:329:9: error: no member named 'isless' in the global namespace
using ::isless;
~~^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:330:9: error: no member named 'islessequal' in the global namespace
using ::islessequal;
~~^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:331:9: error: no member named 'islessgreater' in the global namespace
using ::islessgreater;
~~^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:332:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
~~^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:333:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
另一组与升级相关的错误是这些:
/usr/local/include/stdlib.h:355:21: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
strtoq(const char *__str, char **__endptr, int __base);
^
/usr/local/include/stdlib.h:355:21: note: insert '_Nullable' if the pointer may be null
strtoq(const char *__str, char **__endptr, int __base);
^
_Nullable
/usr/local/include/stdlib.h:355:21: note: insert '_Nonnull' if the pointer should never be null
strtoq(const char *__str, char **__endptr, int __base);
我看过很多与此相关的帖子,我试过以下方法:
- 我一开始并没有使用 Xcode,但我还是尝试下载了它,看看它是否有帮助。没有。
- 多次删除并重新安装 CommandLineTools
- 找到旧版本的 SDK 并尝试用它替换当前的 SDK(即 MaxOSX11.1.sdk),因为 11.3,12.x 也不起作用。
xcrun --show-sdk-path
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
ls -l /Library/Developer/CommandLineTools/SDKs
total 0
lrwxr-xr-x 1 root wheel 14 Feb 20 13:26 MacOSX.sdk -> MacOSX12.1.sdk
drwxr-xr-x 7 root wheel 224 Feb 20 13:26 MacOSX11.3.sdk/
lrwxr-xr-x 1 root wheel 14 Feb 20 13:25 MacOSX11.sdk -> MacOSX11.3.sdk
drwxr-xr-x 7 root wheel 224 Feb 20 13:27 MacOSX12.1.sdk/
lrwxr-xr-x 1 root wheel 14 Feb 20 13:25 MacOSX12.sdk -> MacOSX12.1.sdk
- 运行
xcode-select -s /Library/Developer/CommandLineTools
多次
- 尝试创建手动符号链接以使 /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk 指向我系统上的不同 SDK,但没有成功。
我没有想法(除了硬重置我的 mac,我想避免这种情况)。
这里有一些希望有用的信息:
clang -cc1 version 13.1.6 (clang-1316.0.20.6) default target x86_64-apple-darwin21.3.0
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/Library/Developer/CommandLineTools/usr/lib/clang/13.1.6/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
/Library/Developer/CommandLineTools/usr/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
End of search list.
我所有的东西都备份到 github 但我真的很想避免硬重置。
所以经过更多的挖掘,我最终重命名了一些在 /usr/local/include 中引用的 std 库 h 文件,我的项目又恢复了工作。
重命名了以下文件:
/usr/local/include/_stdio.h -> /usr/local/include/__stdio.h
/usr/local/include/stdio.h -> /usr/local/include/stdio_old.h
/usr/local/include/AvailabilityMacros.h -> /usr/local/include/_AvailabilityMacros.h
/usr/local/include/stdlib.h -> /usr/local/include/_stdlib.h
/usr/local/include/pthread.h -> /usr/local/include/_pthread.h
隐藏这些文件后,编译器正在搜索另一个工作目录headers,项目再次编译没有问题。
我在从 12.1 轻微 OSX 升级到 12.2.1 后编译软件时看到各种错误和警告。
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/unordered_map:411:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__hash_table:18:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:321:9: error: no member named 'signbit' in the global namespace
using ::signbit;
~~^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:322:9: error: no member named 'fpclassify' in the global namespace
using ::fpclassify;
~~^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:323:9: error: no member named 'isfinite' in the global namespace; did you mean 'finite'?
using ::isfinite;
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/unordered_map:411:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__hash_table:18:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:329:9: error: no member named 'isless' in the global namespace
using ::isless;
~~^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:330:9: error: no member named 'islessequal' in the global namespace
using ::islessequal;
~~^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:331:9: error: no member named 'islessgreater' in the global namespace
using ::islessgreater;
~~^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:332:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
~~^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:333:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
另一组与升级相关的错误是这些:
/usr/local/include/stdlib.h:355:21: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
strtoq(const char *__str, char **__endptr, int __base);
^
/usr/local/include/stdlib.h:355:21: note: insert '_Nullable' if the pointer may be null
strtoq(const char *__str, char **__endptr, int __base);
^
_Nullable
/usr/local/include/stdlib.h:355:21: note: insert '_Nonnull' if the pointer should never be null
strtoq(const char *__str, char **__endptr, int __base);
我看过很多与此相关的帖子,我试过以下方法:
- 我一开始并没有使用 Xcode,但我还是尝试下载了它,看看它是否有帮助。没有。
- 多次删除并重新安装 CommandLineTools
- 找到旧版本的 SDK 并尝试用它替换当前的 SDK(即 MaxOSX11.1.sdk),因为 11.3,12.x 也不起作用。
xcrun --show-sdk-path
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
ls -l /Library/Developer/CommandLineTools/SDKs
total 0
lrwxr-xr-x 1 root wheel 14 Feb 20 13:26 MacOSX.sdk -> MacOSX12.1.sdk
drwxr-xr-x 7 root wheel 224 Feb 20 13:26 MacOSX11.3.sdk/
lrwxr-xr-x 1 root wheel 14 Feb 20 13:25 MacOSX11.sdk -> MacOSX11.3.sdk
drwxr-xr-x 7 root wheel 224 Feb 20 13:27 MacOSX12.1.sdk/
lrwxr-xr-x 1 root wheel 14 Feb 20 13:25 MacOSX12.sdk -> MacOSX12.1.sdk
- 运行
xcode-select -s /Library/Developer/CommandLineTools
多次 - 尝试创建手动符号链接以使 /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk 指向我系统上的不同 SDK,但没有成功。
我没有想法(除了硬重置我的 mac,我想避免这种情况)。
这里有一些希望有用的信息:
clang -cc1 version 13.1.6 (clang-1316.0.20.6) default target x86_64-apple-darwin21.3.0
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/Library/Developer/CommandLineTools/usr/lib/clang/13.1.6/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
/Library/Developer/CommandLineTools/usr/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
End of search list.
我所有的东西都备份到 github 但我真的很想避免硬重置。
所以经过更多的挖掘,我最终重命名了一些在 /usr/local/include 中引用的 std 库 h 文件,我的项目又恢复了工作。
重命名了以下文件:
/usr/local/include/_stdio.h -> /usr/local/include/__stdio.h
/usr/local/include/stdio.h -> /usr/local/include/stdio_old.h
/usr/local/include/AvailabilityMacros.h -> /usr/local/include/_AvailabilityMacros.h
/usr/local/include/stdlib.h -> /usr/local/include/_stdlib.h
/usr/local/include/pthread.h -> /usr/local/include/_pthread.h
隐藏这些文件后,编译器正在搜索另一个工作目录headers,项目再次编译没有问题。