How do I install LLVM on macOS Sierra? I've tried brew install llvm
but when trying to use an llvm command like lli I get a command not found error.
homebrew does not link llvm
to /usr/local/bin
because it may conflict with the system one, causing all kinds of nasty bugs. Instead, you should use the full path to invoke them, such as /usr/local/opt/llvm/bin/lli
.
In fact there's a Caveat that's now listed which spells this out...
==> Caveats
==> llvmTo use the bundled libc++ please add the following
LDFLAGS
:
LDFLAGS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib"
llvm is keg-only, which means it was not symlinked into
/usr/local
, because macOS already provides this software and installing another version in parallel can cause all kinds of trouble.If you need to have llvm first in your PATH run:
echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.bash_profile
For compilers to find llvm you may need to set:
export LDFLAGS="-L/usr/local/opt/llvm/lib"
export CPPFLAGS="-I/usr/local/opt/llvm/include"