代码之家  ›  专栏  ›  技术社区  ›  Indiana Kernick Michael Durrant

Homebrew Clang找不到C标准库标题

  •  0
  • Indiana Kernick Michael Durrant  · 技术社区  · 6 年前

    毫不奇怪,OSX Mojave的新更新破坏了我在自制程序中的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以一种新的、不可预测的方式打破了一些东西。

    0 回复  |  直到 6 年前
        1
  •  2
  •   3CxEZiVlQ    6 年前

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

    export LIBCLANG_SYSTEM_INCLUDE_DIR="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include"
    
        2
  •  2
  •   rausted    6 年前

    以下是我解决问题的方法,因为我有书面截止日期,这是我最不担心的:

    1. 在我的Mac上禁用SIP
    2. 符号连接 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include /usr/include 正如posix环境中所期望的那样。
    3. 重新启用SIP。

    现在我要做一个记录,每当一个新的OSX更新出来的时候重新做这个。这没有破坏任何东西,因为xcode,clang(来自brew)等,所以我会保留它。不过,请注意,这可能会弄坏你的东西。

        3
  •  0
  •   Kris Stern    6 年前

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

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

    技巧奏效了,因为现在丢失的文件 “wchar.h” 就在它应该在的地方…事后看来,我本可以把事情简单地联系起来的。干杯!