Homebrew 的 LLVM@12 在 macOS 上出现“致命错误:‘bits/stdc++.h’文件未找到”

问题描述 投票:0回答:1

1.安装LLVM

brew install llvm@12

2.创建目标.cpp

#include <bits/stdc++.h>
  // code

3.当我运行

/opt/homebrew/opt/llvm@12/bin/clang++ dest.cpp -o dest
时,我得到:

fatal error: 'bits/stdc++.h' file not found

1.i 将包含文件 stdc++.h 的目录位添加到路径:

/opt/homebrew/Cellar/llvm@12/12.0.1_1/Toolchains/LLVM12.0.1.xctoolchain/usr/include
,我得到相同的致命

2.我也将它添加到

/opt/homebrew/Cellar/llvm@12/12.0.1_1/include
,但结果是一样的

PS.stdc++.h文件是正确的,因为我添加的时候用成功了

/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/usr/include
,但是添加到llvm@12就不行了

我必须在这里有 stdc++.h,因为我的工作是测试数百个代码,其中大部分都有 stdc++.h,我很难将标头更改为他们真正需要的。

有什么问题吗? 当我运行 /opt/homebrew/opt/llvm@12/bin/clang++ 时是否有可能有 stdc++.h?

macos llvm clang++ libstdc++
1个回答
0
投票

尝试在 Clang++ 中使用

-I /path/to/headerfile
选项,让编译器知道在哪里可以搜索在其标准搜索目录中找不到的头文件:

clang++ dest.cpp -o dest -I /path/to/bits

© www.soinside.com 2019 - 2024. All rights reserved.