2

I just installed clang 3.6. What is the good way to set the system to use the new version. For example, it is installed into /usr/lib/llvm-3.6 directory, but if I am in home directory, and type in clang, it tells me that clang is not installed. So to solve the problem I add the clang bin directory to the path in .bashrc, like so export PATH=$PATH:/usr/lib/llvm-3.6/bin/:/usr/lib/llvm-3.6/lib. That seems to work but it is a bit of a pain, because I use fish and bash, and now I have to add path to both. Is there a better way to configure the system to use the desired llvm banaries? I searched update-alternatives but I am not sure I understand how to use it correctly.

Thanks.

0

1 Answer 1

1

You could probably create a symbolic link (symlink) in a directory that is already a part of both shells' PATH like /usr/local/bin, name it clang and link it to the actual binary in /usr/lib/llvm-3.6/bin or wherever it is:

sudo ln -s /usr/lib/llvm-3.6/bin/clang /usr/local/bin/

That way, the shell finds the link if you type cname, resolves it to the real file and runs that one. It links to the name of the file, so as long as the file name and location of the binary does not get changed, it's fine. You may even replace it with an updated version as long as it is not named differently.

The only alternative is to change your PATH variable.

3
  • It is a good approach, and I do use it, but it seems to be tedious, llvm has lots of binaries. Sep 15, 2015 at 23:49
  • Then you have to set the PATH variables... I can't think of another approach than those two. That does not mean there may not be any other, of course, but at least there's no well known third way.
    – Byte Commander
    Sep 16, 2015 at 8:00
  • @user1135541 Don't thank ByteCommander! ;-) If you like the answer, just click the little grey under the "0" now turning it into beautiful green. If you do not like the answer, click on the little grey down-arrow below the 0, and if you really like the answer, click on the little grey checkmark and the little up-arrow... If you have any further questions, just ask another one!
    – Fabby
    Sep 18, 2015 at 10:59

You must log in to answer this question.

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