[Homebrew] Zsh cannot find the installed llvm

brew install llvm

has triggered the following.

To 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"' >> ~/.zshrc

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"

So, I did


> echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"

> export LDFLAGS=LDFLAGS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib"

> export CPPFLAGS="-I/usr/local/opt/llvm/

and has confirmed they are set.

Though then my clang has changed from Apple one to latest one,


> llvm
zsh: not found llvm

I’m still keep getting this error.

This is why that is not done by default. It is expected that altering PATH replaces what clang gets picked up by your shell.

Because LLVM has no program called “llvm”; there are various “llvm-foo” tools, but no plain “llvm”. I don’t know what you’re trying to do, but this is entirely expected.

1 Like

the compiler name of llvm is clang ?

1 Like

Yes

1 Like
> ls /usr/local/opt/llvm/bin

should show you the installed llvm tools according to your exports above.

1 Like

Thank you everyone. My question got solved.

Lastly, do you think these three following config still necessary?


Looking into this directory, yes, there’s no llvm. And there’s clang, which is what I need for now, the reason I installed llvm, replacing Xcode builtin one.