Set clang-3.8 as default
24,968
Solution 1
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
Solution 2
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.
Solution 3
Try:
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.
Related videos on Youtube
![Andrew](https://i.stack.imgur.com/fXaYa.jpg?s=256&g=1)
Author by
Andrew
Updated on September 18, 2022Comments
-
Andrew almost 2 years
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
?-
Admin almost 8 yearsMake 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/… -
Admin over 5 yearsActually, the name is 'cc'. So you need to issue: sudo update-alternatives --config cc
-
-
John P about 6 yearsI 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. -
banarun over 5 yearsThanks you for the answer. What does the
100
at the end mean? -
jimbouton almost 5 yearsThe '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 andclang
with a priority of 10; in auto mode,update-alternatives
selectsgcc
. I could run the above with a priority of 50 and it would set the auto preference ofclang-3.8
above both existing options