Back to TILs

How to install clang 16 on debian

Date: 2022-12-13Last modified: 2023-02-17

Install key:

wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -

Create source list file:

cat <<EOF > /etc/apt/sources.list.d/llvm.list
deb http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye main
deb-src http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye main
# 14 
deb http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-14 main
deb-src http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-14 main
# 15 
deb http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-15 main
deb-src http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-15 main
# 16 
deb http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-16 main
deb-src http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-16 main
EOF

Update package list and install

apt update
apt-get install \
  clang-16 \
  clang-tools-16 \
  clang-16-doc \
  libclang-common-16-dev \
  libclang-16-dev \
  libclang1-16 \
  clang-format-16 \
  python3-clang-16 \
  clangd-16 \
  clang-tidy-16

To upgrade to the last version:

apt-get install clang lld