Missing Clang and Clang++ Executables Despite Installing Clang-3.5 Package

Feedback

Question:

Upon installation of the

clang-3.5

package, entering

clang

or

clang++

on the command line will display a message informing me of the packages in which those programs can be found. When trying to reinstall

clang-3.5

, apt notifies me that it is already installed and up to date.

The initial installation was carried out using a particular instruction.

sudo apt-get install clang-3.5 llvm


build-essential

had been previously installed.

Can you suggest any possible explanation for what occurred?


Solution 1:

The identifier remains clang-
3.5
, despite its presence.

You have two options to run it: either use

clang-3.5

or

clang++-3.5

. Alternatively, you can create a symlink to it, which is what I did since the regular clang installation 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++

It may not be the most elegant solution, but at least it is currently functional.


Solution 2:


To set clang as the default, it is recommended to utilize

update-alternatives

instead of manually configuring both

cc

and

c++

.

On a single system, it’s feasible to have multiple programs that perform identical or comparable functions installed concurrently. As an instance, numerous text editors are often present on many systems simultaneously. This provides users with the freedom to select a different editor as per their preference, but it poses a challenge for programs to choose an appropriate editor to activate in case the user hasn’t specified a specific preference.

Initially, it is required to incorporate either

clang-3.5

or

clang++-3.5

as substitutes for

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

In case you need to revert to either

gcc

or

g++

, you have the option to use

--config

.

sudo update-alternatives --config c++


Solution 3:


In addition to the clang-x.x package, the clang package can be installed on Ubuntu 15.04. Once installed, the corresponding executable can be accessed by typing clang++.

sudo apt-get install clang


Solution 4:

In addition to Yan Foto’s response, if your goal is to obtain a functional

clang

without necessarily utilizing it as

cc

, you have the option of adding all the programs at once through the following method.

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

Please note that the binaries included with each
clang version
may vary. For instance,
3.6
contains

clang-tblgen

whereas 3.8 does not.

By following this process for each instance of clang you download, you can easily alternate between them with a lone

update-alternatives

directive.

It seems that there is a continuing discussion regarding the inclusion of these links in Ubuntu packages, as per this bug report on Launchpad: https://bugs.launchpad.net/ubuntu/+source/llvm-3.1/+bug/991493.

Frequently Asked Questions