xcode 找不到“wchar.h”文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46342411/
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 10:16:21  来源:igfitidea点击:

'wchar.h' file not found

c++iosxcode

提问by Euphorbium

I know about this question: macOS 'wchar.h' File Not Foundbut it did not help me. I've tried reinstalling xcode, reinstalling command line tools, restarting the system. wchar.h file is in place, but the compiler does not manage to find it. What else could I try? Maybe it is sysroot related? Any way to fix that?

我知道这个问题:macOS 'wchar.h' File Not Found但它对我没有帮助。我试过重新安装 xcode,重新安装命令行工具,重新启动系统。wchar.h 文件已就位,但编译器无法找到它。我还能尝试什么?也许它与 sysroot 相关?有什么办法可以解决吗?

macbooks-MacBook-Pro:Rack euphorbium$ sudo make
c++ -Iinclude -Idep/include -Idep/lib/libzip/include -DVERSION=dev -MMD -O3 -march=core2 -ffast-math -g -Wall -DARCH_MAC -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -mmacosx-version-min=10.7 -DAPPLE -stdlib=libc++ -std=c++11 -stdlib=libc++ -c -o build/src/app.cpp.o src/app.cpp
clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk' [-Wmissing-sysroot]
In file included from src/app.cpp:1:
In file included from include/app.hpp:2:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/vector:265:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/iosfwd:90:
/Library/Developer/CommandLineTools/usr/include/c++/v1/wchar.h:119:15: fatal error: 
      'wchar.h' file not found
#include_next <wchar.h>
              ^~~~~~~~~
1 error generated.
make: *** [build/src/app.cpp.o] Error 1

since wchar.h exists both in the xcode app, and in the /Library/Developer/CommandLineToolsI think that it looks for it in some completely unrelated folder.

因为 wchar.h 既存在于 xcode 应用程序中,又存在于/Library/Developer/CommandLineTools我认为它在一些完全不相关的文件夹中查找它。

采纳答案by alain

I've got the same problem. I was able to fix it by using a symbolic link. This is what I made :

我有同样的问题。我能够通过使用符号链接来修复它。这是我做的:

cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
sudo ln -s MacOSX.sdk MacOSX10.07.sdk  

Then enter your root password.

然后输入你的root密码。

NB: you have to adapt the last line with required sdk.

注意:您必须使用所需的 sdk 调整最后一行。

回答by Kamyar

I had the same problem after upgrading to macOS High Sierra. A project which was compiling before stopped working with this error. In my case, the project files had been generated by the CMake application. The solution was to run CMake, 'Delete Cache', and 'Configure' the project again. This corrected the sysroot directory reference in the make files to point to the new SDK and the error was resolved.

升级到 macOS High Sierra 后我遇到了同样的问题。在此错误停止工作之前正在编译的项目。就我而言,项目文件是由 CMake 应用程序生成的。解决方案是再次运行 CMake、“删除缓存”和“配置”项目。这更正了 make 文件中的 sysroot 目录引用以指向新 SDK,并且错误已解决。

回答by ssh

For any one struggling with this on MacOSX Mojave this answersolves it. In short:

对于在 MacOSX Mojave 上为此苦苦挣扎的任何人,这个答案都能解决。简而言之:

  • Go to the terminal and run open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkgThis will bring up the prompt to install Xcode tools.
  • After that's done got to the terminal and run sudo xcode-select -s /Library/Developer/CommandLineTools
  • 转到终端并运行open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg这将弹出安装 Xcode 工具的提示。
  • 完成后到达终端并运行 sudo xcode-select -s /Library/Developer/CommandLineTools

回答by NeilXu

My system is macOS Mojave, and I've fixed this problem by running this command line:

我的系统是 macOS Mojave,我通过运行以下命令行解决了这个问题:

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

回答by Euphorbium

It was caused by incorrect sysroot, (set for an older mac os version) set in makefiles.

它是由在 makefile 中设置的不正确的 sysroot(为较旧的 mac os 版本设置)引起的。

回答by Kris Stern

I did something dumb but it did fix the problem... Not sure if it will work for your computer though.

我做了一些愚蠢的事情,但它确实解决了问题……但不确定它是否适用于您的计算机。

Here is what I did: I originally installed c++ using Homebrew on my MacBook on Mojave... so I had to manually install the Xcode CommandLineTools using the installer found at /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg. Then I copied the "c++" folder contents from to folder /Library/Developer/CommandLineTools/usr/include/c++/v1to the folder where I want the missing file to be, at /usr/local/Cellar/gcc/8.2.0/include/c++/8.2.0, while replacing files with the same names.

这是我所做的:我最初在 Mojave 上的 MacBook 上使用 Homebrew 安装了 c++ ......所以我不得不使用在/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg. 然后我将“c++”文件夹内容从 to 文件夹复制/Library/Developer/CommandLineTools/usr/include/c++/v1到我希望丢失文件所在的文件夹中, at /usr/local/Cellar/gcc/8.2.0/include/c++/8.2.0,同时替换具有相同名称的文件。

The trick worked, since now the missing file "wchar.h"is right where it should be... Your settings is probably not the same, however, I am afraid.

这个技巧奏效了,因为现在丢失的文件“wchar.h”就在它应该在的地方......但是,我担心你的设置可能不一样。