Skip to content

Installation of Clang

Installing Clang varies depending on the operating system you are using. Below are the instructions for different platforms.

Installation on Linux

On most Linux distributions, you can install Clang using the package manager. Here are the commands for some popular distributions:

Ubuntu

To install Clang on Ubuntu, run the following commands:

sudo apt update
sudo apt install clang

Fedora

To install Clang on Fedora, use the following command:

sudo dnf install clang

Arch Linux

To install Clang on Arch Linux, use the following command:

sudo pacman -S clang

Installation on macOS

On macOS, you can install Clang using Homebrew. If you don't have Homebrew installed, you can install it from brew.sh.

To install Homebrew, run the following command in your terminal:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Once Homebrew is installed, run the following command:

brew install llvm

After installation, you might want to add the LLVM tools to your PATH. You can do this by adding the following line to your .bashrc, .zshrc, or corresponding shell configuration file:

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

Installation on Windows

On Windows, you can install Clang as part of the LLVM project using the LLVM pre-built binaries.

Using the LLVM Pre-built Binaries

  1. Download the LLVM installer from the LLVM releases page.
  2. Run the installer and follow the installation instructions.
  3. Add the LLVM bin directory (usually C:\Program Files\LLVM\bin) to your system PATH.

Using MSYS2

Alternatively, you can install Clang using MSYS2:

  1. Download and install MSYS2 from msys2.org.
  2. Open the MSYS2 shell and update the package database:
pacman -Syu
  1. Install Clang:
pacman -S mingw-w64-x86_64-clang

Verifying the Installation

After installing Clang, you can verify the installation by checking the version:

clang --version