0

I want to know either clang-format-10 can be installed on ubuntu 18.04. Since I have to use clang-format --dry-run option, so I want to know

vvvvv
  • 25,404
  • 19
  • 49
  • 81
min
  • 11
  • 1
  • 3

1 Answers1

3

You can install clang-format-10 on Ubuntu 18.04 by following the steps below:

$ wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
$ echo 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main' | sudo tee -a /etc/apt/sources.list
$ echo 'deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main' | sudo tee -a /etc/apt/sources.list
$ sudo apt update
$ sudo apt search 'clang-format'
...
clang-format-10/unknown 1:10.0.1~++20210314110130+ef32c611aa21-1~exp1~20210314220728.205 amd64
  Tool to format C/C++/Obj-C code
...
$ sudo apt install -y clang-format-10
$ clang-format-10 --version
Ubuntu clang-format version 10.0.1-++20210314110130+ef32c611aa21-1~exp1~20210314220728.205

You can also check this answer for more details.

ocavue
  • 283
  • 3
  • 5
  • sorry, I forgot adding comment. thanks a lot. it was great! – min Mar 26 '21 at 13:48
  • 1
    I have to do few more things: `sudo apt install -y libllvm10` before I can install clang-format-10, and `sudo ln -s /usr/bin/clang-format-10 /usr/bin/clang-format` after install clang-format-10 – TingQian LI Sep 06 '21 at 02:50