After installing the clang-3.5 package, typing clang or clang++ on the command line gives me a message stating which packages those programs can be found in. Attempting to run the install of clang-3.5 again, apt states it's already installed and at the latest version.

The original install was done with the command:

sudo apt-get install clang-3.5 llvm

build-essential was installed previously.

Any ideas on what may have happened?

8 Answers 8


It's there, but it's still called clang-3.5.

You can either execute it as clang-3.5 (or clang++-3.5) or setup a symlink to it like I did (installing regular clang didn't work):

sudo ln -s /usr/bin/clang-3.5 /usr/bin/clang
sudo ln -s /usr/bin/clang++-3.5 /usr/bin/clang++

Ugly work-around, perhaps; but at least it works for now :)

  • For clang-6.0, I have to do this in addition: ln -s /usr/bin/llc-6.0 /usr/bin/llc Oct 10, 2018 at 9:59

The proper way to use clang as your default cc and c++ is to use update-alternatives:

It is possible for several programs fulfilling the same or similar functions to be installed on a single system at the same time. For example, many systems have several text editors installed at once. This gives choice to the users of a system, allowing each to use a different editor, if desired, but makes it difficult for a program to make a good choice of editor to invoke if the user has not specified a particular preference.

so first you need to add clang-3.5 or clang++-3.5 as alternatives to e.g. gcc and g++:

sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang-3.5 100
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-3.5 100

If at any time you need to switch back to gcc or g++ you can use the --config option:

sudo update-alternatives --config c++
  • Could you add some extra explanation regarding the arguments? Why cc / c++ in between the two paths? What is that 100 in the end? Priority?
    – helmesjo
    Aug 29, 2018 at 9:43
  • Take a look at update-alternatives docs. I think they have a better explanations than anything I would summarize here.
    – Yan Foto
    Sep 3, 2018 at 7:55

On Ubuntu 15.04 you can also install the clang package along the clang-x.x package. You can then type clang++ and the according executable should be found.

sudo apt-get install clang
  • 1
    Wouldn't "apt-get install clang" simply install the latest version, and then use it? If the OP is installing v3.5, he does not want to use the latest one.
    – amfcosta
    May 8, 2017 at 18:13
  • This was the only solution for me. I run sudo apt install clang-3.8 (and it installed all required), but clang was still not recognized on my system until I ran sudo apt install clang and all issues were resolved.
    – SilSur
    May 12, 2020 at 12:50

Adding to Yan Foto's answer (and just in case your aim is to get a usable clang but not necessarily use it as cc), you can actually add the entire set of programs in one go using

sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.8 380 \
--slave /usr/bin/clang++ clang++ /usr/bin/clang++-3.8 \
--slave /usr/bin/clang-check clang-check /usr/bin/clang-check-3.8 \
--slave /usr/bin/clang-query clang-query /usr/bin/clang-query-3.8 \
--slave /usr/bin/clang-rename clang-rename /usr/bin/clang-rename-3.8

(Note that the set of binaries that come with each clang version might differ, e.g. 3.6 does have clang-tblgen, 3.8 doesn't.)

If you repeat this for every version of clang you install, you'll be able to switch between them using just a single update-alternatives command.

(Meanwhile, apparently, there is still an ongoing debate about whether to include these links with Ubuntu packages or not: https://bugs.launchpad.net/ubuntu/+source/llvm-3.1/+bug/991493)


This should set the update-alternatives for clang-4.0 if clang-3.8 (as on Ubuntu 16.04) is installed:

sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-4.0 100
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-4.0 100
sudo update-alternatives --install /usr/bin/clang-apply-replacements clang-apply-replacements /usr/bin/clang-apply-replacements-4.0 100
sudo update-alternatives --install /usr/bin/clang-check clang-check /usr/bin/clang-check-4.0 100
sudo update-alternatives --install /usr/bin/clang-query clang-query /usr/bin/clang-query-4.0 100
sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-4.0 100
sudo update-alternatives --install /usr/bin/scan-build scan-build /usr/bin/scan-build-4.0 100
sudo update-alternatives --install /usr/bin/scan-view scan-view /usr/bin/scan-view-4.0 100

Create a .bashrc file in your home directory. Type this line of code.

alias clang++="clang++-3.5"

Close your terminal. Open it up again. Then try to compile your program again.

From what I can tell clang won't work unless you state the version in the command name "clang++-3.5". So I just aliased the name in my .bashrc file. So I only have to type "clang++".

By the way I downloaded clang 3.5, so adjust the previous advice to your version.


If you have clang correctly installed, another very easy way to save you the trouble of typing the version number along with the name of the program is to use the auto-completion feature, for example (having clang++-3.5 installed):


So you only have to type clang+, hit Tab and Enter. Works the same way with names of directories, file names, etc. (This won't help you, however, if you have more than one version of a program installed.)


Adding to Johann Wendin's answer about symlinking. In a root-shell you can link all the various clang tools at once:


find /usr/bin/ -name clang*  | sed -E 's/^(\/usr\/bin\/.*)(\-[0-9]*)$/ln -s -v \1\2 \1/' | xargs -d '\n' -n 1 bash -c

and then repeat for:


Then everything should be linked, not just a small selection. (Maybe I still forgot something).

This will find all the files according to the pattern in /usr/bin, remove any trailing numbers (-8 or -9 or even -10), and then create symlinks on each.

You must log in to answer this question.

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