Building software on Mac is always a pain, for anything that require
clang/cc/gcc. Because some tooling come from homebrew, some come from Xcode. And
when from XCode, there is two way, one in /Library/Developer/CommandLineTools
and other in /Applications/Xcode.app/Contents/Developer
. Depends on a lot of
factor around your path and env, sometime error happen and really hard to debug
if you’re familiar with C.
Today, I want to share a quick note on this error:
When you run go build and get this error
# runtime/cgo
_cgo_export.c:3:10: fatal error: 'stdlib.h' file not found
Then check your PATH, chance is you have something llvm
path in your PATH
so
cland
binary will be from homebrew:
/opt/homebrew/opt/llvm@[version-here]/bin/clang
You need to remove it, either unlink it, remove it, or update your path to switch to the right cland from xcode commandline tool.
$ which clang
/usr/bin/clang
A simple fix could be.