macosclangclang++

How to install updated clang 16?


all.

I need to install clang 16 on my computer in order to get -std=c++17 support. Currently, I have the following after running the following:

clang --version

output:

Apple clang version 15.0.0 (clang-1500.1.0.2.5)
Target: x86_64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

In order to install a new clang version, it was recommended that I remove command line tools using this tutorial. Then, basically reinstall them and I would get an update.

Now, after following the tutorial, I have the following output for my clang version:

Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: x86_64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

In essence, I did the opposite of what I wanted which was depreciate my clang. Is it possible to update to 16.0 using xcode-select? Thanks.


Solution

  • On macOS devices, try to use brew for installing clang. Brew installation instruction is on their homepage.

    To install clang, use the llvm package on brew. Run

    brew install llvm
    

    to install the latest version of clang and llvm.

    You should see the latest clang installed with clang -v. If you don't see it, update your path.

    export PATH=/opt/homebrew/opt/llvm/bin:$PATH