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.
All of Apple's operating systems, iOS, macOS, tvOS and watchOS, are built with LLVM technologies.
Your LLVM will be installed in /usr/local/opt/llvm .
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"
You can also add /usr/local/opt/llvm/bin/
to your $PATH environment variable:
echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
This way you can call other llvm
commands such as llvm-config
. A list of llvm can be found here.
Remember to source .bash_profile
! I wasted a lot of time due to the silly problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With