10

I have 22.04 LTS but I'd like to install a later Clang, version 16.

How can I install this?

(22.04 doesn't come with Clang 16 in the repos)

UPDATE

Whilst I appreciate the answer below, I found a much simpler way from here:

https://askubuntu.com/a/1415641/132414 https://apt.llvm.org/

To install a specific version of LLVM:
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh <version number>

1 Answers1

2

Cland 16 has pre-build packages available to download at its github releases page.

In the case, you can select download the clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz package for modern pc and laptop.

It's a non-install package, just extract it in your file manager, right-click on the bin sub-folder and select 'Open in Terminal'. Then run any executable file to compile your programs, such as ./clang-16 -x c++ .....

For any errors like below:

error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory

Search the key file (libtinfo.so.5 in the case) in packages.ubuntu.com under "Search the contents of packages" section. Then install the corresponding package (libtinfo5 in the case).

And, if you use Clang 16 frequently, then you can add the 'bin' into PATH. So, you don't have to navigate to that folder every time running clang-16 executable. There are quite a few tutorials talking about it. Here's one that I made.