Mac OS、LLVM 3.7 和缺失 math.h header
Mac OS, LLVM 3.7 and missing math.h header
我需要在 Mac OS 10.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 -
产生此错误的真实代码是我尝试 运行 ghc -fllvm
一个简单的 helloworld.hs 代码,我想将其作为 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
headers.
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.0.2
我错过了什么?
我已经意识到我的错误所在:我应该在 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/
我需要在 Mac OS 10.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 -
产生此错误的真实代码是我尝试 运行 ghc -fllvm
一个简单的 helloworld.hs 代码,我想将其作为 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
headers.
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.0.2
我错过了什么?
我已经意识到我的错误所在:我应该在 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/