我需要在MacOS10.12上使用旧版本的LLVM,即3.7,因为ghc需要它。
我已经通过brew install llvm@3.7安装了它。
现在,即使是做最简单的事情,我也会收到<stdin>:1:10: fatal error: 'math.h' file not found错误:
echo '#include <math.h>' | clang-3.7 -xc -v -产生这个错误的真正代码是我试图在一个简单的helloworld.hs代码上运行ghc -fllvm,我想把它作为LLVM。
我已经做到了:
$ find /usr/local/Cellar/llvm\@3.7 | grep math
/usr/local/Cellar/llvm@3.7/3.7.1/lib/llvm-3.7/include/c++/v1/cmath
/usr/local/Cellar/llvm@3.7/3.7.1/lib/llvm-3.7/include/c++/v1/ctgmath
/usr/local/Cellar/llvm@3.7/3.7.1/lib/llvm-3.7/include/c++/v1/tgmath.h
/usr/local/Cellar/llvm@3.7/3.7.1/lib/llvm-3.7/lib/clang/3.7.1/include/tgmath.h我发现没有任何math.h标头。
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.0.2我遗漏了什么?
发布于 2017-02-09 09:30:19
我已经意识到我的错误所在:我应该在C头文件中查找缺少的math.h,而不是C++头文件。
将以下任一项添加到/usr/local/Cellar/ghc/8.0.2/lib/ghc-8.0.2/settings中的C编译器标志可解决此问题:
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
或
-idirafter /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/
https://stackoverflow.com/questions/42125971
复制相似问题