As of now you can just do

brew install llvm

For me this installed llvm and clang 4.0.0 to /usr/local/opt/llvm

Answer from Timmmm on Stack Overflow
๐ŸŒ
UCI ICS
ics.uci.edu โ€บ ~pattis โ€บ common โ€บ handouts โ€บ macclion โ€บ clang.html
Clang C/C++ Download and Installation Instructions
The version I installed (on 9/16/2016) is Apple version LLVM 6.0 (clang-600.0.57) (based on LLVM 3.5svn). After following the instruction here, you will download a version of CLion, an Integrated Development Environment (IDE) for using these compilers (or you can choose to use these compilers ...
๐ŸŒ
Clang
clang.org โ€บ download.html
Download - The Clang Compiler Open Source Project
Install the official XCode command ... install including the clang compiler driver. This has to be done from within the IDE. Click the Xcode button in the top left of the screen near the Apple logo, then click Preferences, then click Downloads....
Discussions

macos - How to install 'clang++' on OS X - Stack Overflow
I've have got a default clang and clang++ in the /usr/bin/ directory. Both of them is version 3.3. Also I've installed clang with help of this specification. After installation, I've gotten additio... More on stackoverflow.com
๐ŸŒ stackoverflow.com
development - How to install recent clang++ with Homebrew? - Ask Different
So both clangs on mac os is broken. You have to build it with all features enabled from source. But compilation will kill your CI like travis. So you have to host and maintain separate CI only for apple. Apple is good only for simple development, anything else requires pain. ... $ brew install --with-clang llvm ==> Installing dependencies for llvm: cmake ==> Installing llvm dependency: cmake ==> Downloading ... More on apple.stackexchange.com
๐ŸŒ apple.stackexchange.com
February 11, 2016
c++ - How can I download and install a particular version of Clang on OS X? - Stack Overflow
This is right now what shows on my machine: clang --version Apple LLVM version 10.0.0 (clang-1000.10.44.4) Target: x86_64-apple-darwin17.7.0 Thread model: posix InstalledDir: /Library/Developer/ More on stackoverflow.com
๐ŸŒ stackoverflow.com
How to install clang 18(iMac M3)
How are you installing Clang? Xcode does not force you to do anything. It just sits there. I have Xcode and Clang 18 both installed on my computer and it works fine. I donโ€™t know what problems you are running into. More on reddit.com
๐ŸŒ r/cpp_questions
10
0
September 8, 2024
๐ŸŒ
Clang
clang.llvm.org โ€บ get_started.html
Getting Started: Building and Running Clang - LLVM.org
Clang is released as part of regular LLVM releases. You can download the release versions from https://llvm.org/releases/. Clang is also provided in all major BSD or GNU/Linux distributions as part of their respective packaging systems. From Xcode 4.2, Clang is the default compiler for Mac OS X.
Top answer
1 of 2
16

As of now you can just do

brew install llvm

For me this installed llvm and clang 4.0.0 to /usr/local/opt/llvm

2 of 2
9

I suspect all you were missing was libstdc++ but trying to figure that out without seeing your build log is impossible. Especially as you say 'after installation...' when there's no installation step in the instructions you link to, only build?

So, I'm going to suggest you use brew to do the install along with the dependencies. llvm35 is a bit bleeding edge but the current instructions that install that with brew are:

Step 1: make sure you have a recent enough gcc/libc to build clang (may not be necessary for you):

$ brew install gcc47 

Step 2: install the HEAD version of llvm35 with all the trimmings (see https://github.com/Homebrew/homebrew-versions/issues/340 - you MUST read this, because we are building HEAD versions the instructions might be updated tomorrow. Correct just now, I just built it!):

$ brew install isl --HEAD
$ brew install --cc=gcc-4.7 --HEAD llvm35 --with-asan --with-clang --with-libcxx --rtti --all-targets
# wait....
๐Ÿบ  /usr/local/Cellar/llvm35/HEAD: 1427 files, 240M, built in 18.3 minutes

$ /usr/local/Cellar/llvm35/HEAD/bin/clang++-3.5 -v
clang version 3.5 
Target: x86_64-apple-darwin12.5.0
Thread model: posix

Note my command differs from the one in the link by including --cc=gcc-4.7 to use the gcc installed in step 1; if your gcc is already good enough, you won't need that. This is installed keg-only so won't be in the usual paths (see: https://github.com/Homebrew/homebrew/wiki/FAQ, by 'Cellar' they mean /usr/local/Cellar; I've shown the path mine built above)

๐ŸŒ
MacPorts
ports.macports.org โ€บ port โ€บ clang-17
Install clang-17 on macOS with MacPorts
To install clang-17, run the following command in macOS terminal (Applications->Utilities->Terminal)
๐ŸŒ
MacPorts
ports.macports.org โ€บ port โ€บ clang-12
Install clang-12 on macOS with MacPorts
To install clang-12, run the following command in macOS terminal (Applications->Utilities->Terminal)
๐ŸŒ
k0nze
k0nze.dev โ€บ posts โ€บ use-alternative-c-cpp-compiler-on-apple-silicon
How to install an Alternative C/C++ Compiler (GCC/Clang) on macOS (Apple Silicon Mac M1/M2/M3) | k0nze
January 30, 2024 - If you are using an Intel-based Mac you have to download a TAR bundle with includes x86_64-apple-darwin in its name. After the download has finished, navigate into your download directory using the Terminal and unpack the TAR bundle with the following command: Now there is a directory with ...
Find elsewhere
๐ŸŒ
LLVM
releases.llvm.org โ€บ download.html
LLVM Download Page
Clang for Windows (64-bit) (.sig) OpenMP run-time included in packages targeting Windows, x86_64 Linux, and x86_64 FreeBSD. ... OpenMP run-time included in packages targeting i386 and x86_64 Linux, x86_64 FreeBSD, and Darwin. Signed with PGP key 345AD05D. ... Signed with PGP key 345AD05D. ... Signed with PGP key 345AD05D. ... Mac OS/X universal tarball with llvm-gcc 4.0 and all other LLVM tools This is most useful if you want a no-fuss drop-in replacement for Apple GCC.
Top answer
1 of 4
46

Now it's enough to run:

brew install llvm

The bottle now includes clang by default.

2 of 4
25

As of 2018, the Homebrew Versions repository ('tap') is out of service.

The stock Homebrew llvm package still doesn't include clang/clang++, by default. Thus, it isn't part of the prebuilt ('bottled') package.

One can build it via:

brew install --with-toolchain llvm

And then use it via e.g.:

$ PATH="/usr/local/opt/llvm/bin:$PATH" \
    LDFLAGS='-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib' \
    cmake ...

But this --with-toolchain induced build takes a very long time and is thus unsuitable in a continuous integration (CI) environment.

However, the clang that comes with recent XCode (which is available in CI environments like Travis-CI, Version 9 is the default, 10 available, too) isn't that outdated anymore as it used to be (Apple uses an fantasy version scheme for clang that doesn't match upstream clang version numbers but cmake detects e.g. for AppleClang 9.1.0.9020039 the version 4.0.1). Thus, it is sufficient to build C++11/C++14 software with common dependencies like Boost (e.g. version 1.67).

2016 State of the Art

The llvm package in Homebrew doesn't include clang++, by default. When installing it, you have to add --with-clang to the command line (e.g. brew install --with-clang llvm). The extra --with-clang yields a full package compile because there is only one prebuild ('bottled') llvm package available (without clang++). In addition to that: the llvm package is relatively old - currently it has llvm 3.6 - where 3.7 was released 6 months ago.

Thus, to get a bottled clang++ 3.7 you have to install the llvm package from Homebrew Versions:

$ brew tap homebrew/versions
$ brew install llvm37

It is then available under:

/usr/local/bin/clang++-3.7

The formula also notes:

To link to libc++, something like the following is required:
  CXX="clang++-3.7 -stdlib=libc++"
  CXXFLAGS="$CXXFLAGS -nostdinc++ -I/usr/local/opt/llvm37/lib/llvm-3.7/include/c++/v1"
  LDFLAGS="$LDFLAGS -L/usr/local/opt/llvm37/lib/llvm-3.7/lib"
๐ŸŒ
App Store
apps.apple.com โ€บ us โ€บ app โ€บ c-c-llvm-clang โ€บ id1016290003
C/C++ LLVM Clang - App Store - Apple
Download C/C++ LLVM Clang by ๅฐๆ–‡ ้ป„ on the App Store. See screenshots, ratings and reviews, user tips, and more apps like C/C++ LLVM Clang.
Rating: 4.3 โ€‹ - โ€‹ 50 votes
๐ŸŒ
Visual Studio Code
code.visualstudio.com โ€บ docs โ€บ cpp โ€บ config-clang-mac
Using Clang in Visual Studio Code
November 3, 2021 - To verify that it is, open a macOS Terminal window and enter the following command: ... If Clang isn't installed, enter the following command to install the command line developer tools, which include Clang:
๐ŸŒ
Embedded Artistry
embeddedartistry.com โ€บ home โ€บ blog โ€บ installing llvm/clang on os x
Installing LLVM/Clang on OS X - Embedded Artistry
July 6, 2023 - Every time I open a new terminal, it prompt "clang: error: no input files". How can I avoid it? ... โžœ Downloads clang-tidy a.cpp -checks=-*,misc-use-after-move -- 1 error generated. Error while processing /Users/feizhao/Downloads/a.cpp.
๐ŸŒ
MacPorts
ports.macports.org โ€บ port โ€บ clang-14
Install clang-14 on macOS with MacPorts
To install clang-14, run the following command in macOS terminal (Applications->Utilities->Terminal)
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 55464603 โ€บ how-can-i-download-and-install-a-particular-version-of-clang-on-os-x
c++ - How can I download and install a particular version of Clang on OS X? - Stack Overflow
What do you mean by "no luck"? Normally, you would need to modify your PATH variable to add the other clang to it. If homebrew does not work for you for some reason, then consider using prebuilt binaries from the official website: releases.llvm.org.
๐ŸŒ
MacPorts
ports.macports.org โ€บ port โ€บ clang-16
Install clang-16 on macOS with MacPorts
To install clang-16, run the following command in macOS terminal (Applications->Utilities->Terminal)
๐ŸŒ
MacPorts
ports.macports.org โ€บ port โ€บ clang-15
Install clang-15 on macOS with MacPorts
To install clang-15, run the following command in macOS terminal (Applications->Utilities->Terminal)
๐ŸŒ
Clang
clang.llvm.org
Clang C Language Family Frontend for LLVM
The Clang project provides a language front-end and tooling infrastructure for languages in the C language family (C, C++, Objective C/C++, OpenCL, and CUDA) for the LLVM project. Both a GCC-compatible compiler driver (clang) and an MSVC-compatible compiler driver (clang-cl.exe) are provided.