c++ - ' fatal error : 'wchar.h' file not found' error with the new macos 11. 3 更新

标签 c++ xcode sdk wchar xcode-command-line-tools

我对 C++ 完全陌生(昨天才从头开始学习)。 今天我将 macos 更新到 11.3,现在当我在 clion 中运行我的 c++ 代码时,出现此错误,

====================[ Build | untitled | Debug ]================================
/Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake --build /Users/nibin/CLionProjects/untitled/cmake-build-debug --target untitled -- -j 6
[ 50%] Building CXX object CMakeFiles/untitled.dir/main.cpp.o
clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk' [-Wmissing-sysroot]
In file included from /Users/nibin/CLionProjects/untitled/main.cpp:1:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iostream:37:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ios:214:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iosfwd:95:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/wchar.h:119:15: fatal error: 'wchar.h' file not found
#include_next <wchar.h>
              ^~~~~~~~~
1 error generated.
make[3]: *** [CMakeFiles/untitled.dir/main.cpp.o] Error 1
make[2]: *** [CMakeFiles/untitled.dir/all] Error 2
make[1]: *** [CMakeFiles/untitled.dir/rule] Error 2
make: *** [untitled] Error 2

我上网查了一下,但一个字也没听懂。我确实尝试了其中一些并在我的终端中得到了它,

➜  ~ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
➜  ~ xcrun --show-sdk-path
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
➜  ~ sudo xcode-select --switch /Library/Developer/CommandLineTools/
Password:
➜  ~ xcrun --show-sdk-path
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk

我已经有了 xcode 工具并且它是最新的。我尝试了其中一种解决方案,即更改路径,但仍然不起作用。所以我只是将文件带回原来的位置,

➜  ~ sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/
➜  ~ xcrun --show-sdk-path
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk

我尝试了另一种解决方案,但出现错误,

➜  ~ open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
The file /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg does not exist.

我打开了/Library/Developer/CommandLineTools/并得到了这个,

➜  ~ cd /Library/Developer/CommandLineTools
➜  CommandLineTools ls
Library SDKs    usr

一些涉及清除缓存的解决方案“删除当前项目和依赖项中任何旧的 CMakeCache.txt 并重建可以解决问题。”抱歉,如果这听起来很愚蠢,但我不太明白。这是否意味着我们必须删除整个文件 CMakeCache.txt 还是只是内容。

最佳答案

“我们认为 Tools | CMake | Reset Cache and Reload project 在这种情况下应该有所帮助。” (https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000919219-Clion-can-t-compile-because-of-wchar-h-not-found-after-updated-Mojave-in-mac-) 这对我有用

关于c++ - ' fatal error : 'wchar.h' file not found' error with the new macos 11. 3 更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67303146/

相关文章:

javascript - OSX 上的 Swift : WebView stringByEvaluatingJavaScriptFromString doesn't work

ios - 代码 8 : send email from simulator

sdk - VSIX 在实验实例(调试)中加载,但在非实验实例中不加载

c++ - Cmake 编译具有 VTK 依赖性的目录中的所有 c++ 文件

C++:重新排序原子存储(发布)和加载(获取)

objective-c - 在 Cocoa Mac Os X 桌面应用程序中,我可以配置项目以便将没有扩展名的文件拖到应用程序的图标中吗?

javascript - Microsoft Speech-to-Text SDK JS 不接受具有长字节数组的文件

c++ - 使用 std::vector 或数组初始化 boost 矩阵

c++ - Rcpp - 如何在 C++ 代码中使用分布函数

ios - Gigya SDK 的 Google 登录问题