如何在 Ubuntu 18.04 上安装 clang-14?

如何在 Ubuntu 18.04 上安装 clang-14?

您能帮我在 Ubuntu 18.04 上安装 clang-14 吗?我认为我需要一个有效的 repo,因为 apt-get install clang-14 不起作用。

$ 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

答案1

您可以按照此处 llvm 页面上的说明下载 clang 14:

wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 14

答案2

你需要 bionic 中的 ubuntu-toolchain-r ppa

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

现在已经安装了 clang-14 和 clang++-14 。

答案3

clang-14尚无法供您发布...但是从 Ubuntu 22.04 开始可用

因此,您可能需要考虑升级到 22.04。

相关内容