5

Can you help me install clang-14 on Ubuntu 18.04? I think I need a valid repo as apt-get install clang-14 does not work.

$ cat /etc/issue
Ubuntu 18.04 LTS \n \l

$ sudo apt-get update
Hit:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
Hit:2 http://us.archive.ubuntu.com/ubuntu bionic InRelease
Hit:3 http://us.archive.ubuntu.com/ubuntu bionic-updates InRelease
Reading package lists... Done

$ sudo apt-get install clang-14
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package clang-14

$ clang++ -v
clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.5.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
2

3 Answers 3

10

You can download clang 14 for with the instructions on the llvm page here:

wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 14
2
  • It fails with the following: Distribution 'ubuntu' in version '18.04.6 LTS (Bionic Beaver)' is not supported by this script.
    – fsquirrel
    Aug 4, 2022 at 10:06
  • It worked for me for clang-12 as well. just changed last line sudo ./llvm.sh 12
    – DevMJ
    Dec 16, 2022 at 16:59
1

You neded ubuntu-toolchain-r ppa in bionic

sudo add-apt-repository ppa:ubuntu-toolchain-r/test

sudo apt update && sudo apt upgrade

wget https://apt.llvm.org/llvm.sh

chmod +x llvm.sh

sudo ./llvm.sh 14

And now are installed with clang-14 and clang++-14 .

1
  • Would this allow installing Clang 16 on 22.04? Jun 20, 2023 at 21:51
0

clang-14 is not available for your release ... but available as of Ubuntu 22.04

So, upgrading to 22.04 is what you might want to consider.

2
  • Thanks for the clarification! Jun 24, 2022 at 16:52
  • Updating to Ubuntu 22.04 is not always possible. Both because there are a lot of performance downgrades that make it undesirable (snap everywhere, for example), but also because: on work servers, we can't just choose to upgrade, that's decided at a totally different organizational level.
    – James
    Feb 8, 2023 at 18:54

You must log in to answer this question.

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