通过Homebrew进行的MacOS叮当声在Mojave`wchar.h`

时间:2018-11-01 15:34:27

标签: c++ macos clang llvm macos-mojave

不足为奇的是,OSX Mojave的新更新中断了我在Homebrew中的llvm安装,这些是我尝试的步骤:

xcode-select --install # Complained, so I installed commandLineTools from here https://developer.apple.com/download/more/
xcode-select -p /Library/Developer/CommandLineTools
xcode-select --install # Now says installed
sudo xcodebuild -license # Fails, as it says I only have CommandLineTools installed in /Library/Developer/CommandLineTools not xcode

# Try something else (all versions)
brew uninstall --force llvm
brew install llvm # yay v7 how exciting

# Only it still don't work
clang++ -std=c++17 foo.cpp -o f
In file included from foo.cpp:1:
In file included from /usr/local/Cellar/llvm/7.0.0/include/c++/v1/iostream:38:
In file included from /usr/local/Cellar/llvm/7.0.0/include/c++/v1/ios:215:
In file included from /usr/local/Cellar/llvm/7.0.0/include/c++/v1/iosfwd:90:
/usr/local/Cellar/llvm/7.0.0/include/c++/v1/wchar.h:119:15: fatal error: 'wchar.h' file not found
#include_next <wchar.h>
              ^~~~~~~~~
1 error generated.

有什么想法吗?我尝试在网上找到的上半部分内容,但主要是用于MacOS的较旧更新,也许Mojave以一种新的且不可预测的方式破坏了这些内容。

3 个答案:

答案 0 :(得分:3)

考虑到我有书面截止日期,这是我解决的方法,这是我最少的担心:

  1. 在Mac上禁用了SIP
  2. 在POSIX环境中,将/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include链接到/usr/include
  3. 重新启用SIP。

现在,每当新的OSX更新发布时,我都要记下重新进行此操作。这并没有破坏Xcode,clang(来自brew)等任何东西,所以我会保留它。但请注意,这可能会损坏您的东西。

答案 1 :(得分:2)

这是最新的macOS的著名问题。尝试设置此环境变量,它必须解决此问题。

export LIBCLANG_SYSTEM_INCLUDE_DIR="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include"

答案 2 :(得分:0)

我做了一些愚蠢的操作,但确实解决了问题。

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

这个技巧奏效了,因为现在丢失的文件“ wchar.h” 正好在应该存在的位置...事后看来,我本来可以实现simlink。干杯!