I have installed clang 3.0 and clang 3.8:

$ sudo update-alternatives --config clang

update-alternatives: error: no alternatives for clang.

How can I set 3.8 as /usr/bin/clang?

  • Make one or more clang entries to /etc/alternatives/ : sudo update-alternatives --install "/usr/bin/clang" "clang" "[path-to]/clang" 1000 , like this java example askubuntu.com/questions/56104/… Jun 26, 2016 at 20:36
  • Actually, the name is 'cc'. So you need to issue: sudo update-alternatives --config cc
    – duli
    Dec 15, 2018 at 16:23

3 Answers 3

sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.8 100

sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.8 100
  • I was following another example that used '60' to represent '6.0' and --slave instead of independent rules - what are your thoughts? update-alternatives doesn't look like it's doing much more than chaining symlinks, but I haven't used it enough to know what can go wrong.
    – John P
    Jun 4, 2018 at 10:04
  • Thanks you for the answer. What does the 100 at the end mean?
    – banarun
    Feb 1, 2019 at 12:53
  • The '100' is an arbitrary priority number; the application with the highest priority number will be used automatically unless you specify otherwise. For example, my system shows gcc with a priority of 20 and clang with a priority of 10; in auto mode, update-alternatives selects gcc. I could run the above with a priority of 50 and it would set the auto preference of clang-3.8 above both existing options
    – arclight
    Aug 3, 2019 at 16:22
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-8   81 --slave /usr/bin/clang++ clang++ /usr/bin/clang++-8    --slave /usr/share/man/man1/clang.1.gz clang.1.gz /usr/share/man/man1/clang-8.1.gz --slave /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-8  --slave /usr/bin/clang-format clang-format /usr/bin/clang-format-8
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-6.0 60 --slave /usr/bin/clang++ clang++ /usr/bin/clang++-6.0  --slave /usr/share/man/man1/clang.1.gz clang.1.gz /usr/share/man/man1/clang-6.0.1.gz --slave /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-6.0 --slave /usr/bin/clang-format clang-format /usr/bin/clang-format-6.0

These commands will add 2 entries and default selected as clang-8. You can configure using

sudo update-alternatives --config clang

This will update clang, clang++, man pages, clang-format, clang-tidy.



sudo update-alternatives --config cc

And it will present the list of options for you to choose.

make utility uses the command cc to compile, which is actually a link to gcc, clang etc.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .