【问题标题】:MacOS clang via Homebrew broken under Mojave `wchar.h` [duplicate]MacOS 通过在 Mojave `wchar.h` 下损坏的 Homebrew 发出叮当声 [重复]
【发布时间】:2018-11-01 15:34:26
【问题描述】:

不出所料,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 以一种新的、不可预测的方式破坏了东西。

【问题讨论】:

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


【解决方案1】:

这是我解决它的方法(很脏但已经工作了很长时间):

  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)等任何东西,所以我会保留它。不过请注意,这可能会破坏您的东西。

【讨论】:

  • 这对我有用,但我真的不喜欢它。我现在每次更新时都必须以恢复模式重新启动并运行脚本。恢复模式真的很不爽。三指拖动被禁用。鼠标灵敏度略低。键重复被禁用。许多命令行工具似乎不在我的 PATH 中,所以我不得不使用绝对路径来访问 micro(nano 的继承者)。
【解决方案2】:

这是最新 macOS 的一个众所周知的问题。尝试设置这个环境变量,它必须解决这个问题。

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

【讨论】:

  • 众所周知在哪里?因为我从昨天开始就一直在寻找解决方案。还有为什么要否决它根本不直观!
  • 我从我的大学得到了这个解决方案。由于此 macos 存在 SDK 和 clang 问题,我们公司禁止将 macos 升级到 Mojave。
  • 我明白了,不幸的是,这对我不起作用,尽管将 envvar 放在我的 bash_profile 中,我仍然遇到同样的错误。
【解决方案3】:

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

这是我所做的: 我最初在 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" 就在它应该在的地方......事后看来,我可以进行 simlinked。干杯!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-20
    • 2019-03-14
    相关资源
    最近更新 更多