首页 > 系统相关 >How to install Clang 17 or 18 in Ubuntu 22.04 20.04

How to install Clang 17 or 18 in Ubuntu 22.04 20.04

时间:2024-01-23 09:00:27浏览次数:45  
标签:17 script 18 apt Clang install Ubuntu

How to install Clang 17 or 18 in Ubuntu 22.04 | 20.04

This simple tutorial shows how to install the latest Clang compiler 17 and/or 18 in Ubuntu 20.04, Ubuntu 22.04, and Ubuntu 23.10.

Ubuntu includes several versions of Clang in its system repositories. But, it rarely builds newer releases into Ubuntu stable repositories.

You can easily install Clang 10, 11, 12, 13, 14, and 15 by running sudo apt install clang-xx (replace xx with major version number) command in terminal.

For the most recent 18 and 17, they are also easy to install via the official apt repository.

Step 1: Download the Automatic installation script

The official Clang repository, so far supports Ubuntu 18.04, Ubuntu 20.04, Ubuntu 22.04, Ubuntu 23.04, and Ubuntu 23.10. It has a script to make adding repository and installing Clang as easy as few Linux commands.

  1. First, open terminal. When terminal opens, run command to download the official installation script:

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

    You may also use the script in Debian stable, though you may need to install wget first.

  2. After downloading the script, add executable permission by running command:

    chmod u+x llvm.sh
    

Step 2: Use the script to install Clang

The script automate the process of adding the official apt repository, updating package cache, and installing specific Clang version into your system.

All this can be done by running a single command. For example, install Clang-18:

sudo ./llvm.sh 18

Replace 18 with 17 for installing Clang-17, or even 19 if it’s already released when you see this tutorial

During the process, it will ask to hit Enter to confirm adding the apt repository. Then, you may just wait until the process done.

Step 3: Verify

If everything’s done successfully, just run clang-xx --version and/or locate clang-xx to verify.

Uninstall

To remove the repository added by the script, just open terminal (Ctrl+Alt+T) and run command to remove the corresponding source file:

sudo rm /etc/apt/sources.list.d/archive_uri-http_apt_llvm_org_*.list

And, remove the repository key file via command:

sudo rm /etc/apt/trusted.gpg.d/apt.llvm.org.asc

Or, launch “Software & Updates” and remove source line and key from “Other Software” and “Authentication” tabs.

Only Sample for user

To remove Clang packages (replace 18 accordingly), just run command:

sudo apt remove --autoremove clang-18 lldb-18 lld-18 clangd-18

标签:17,script,18,apt,Clang,install,Ubuntu
From: https://www.cnblogs.com/RioTian/p/17981544

相关文章

  • 9.18 比赛总结
    题目。A,B水,D随便一种算法找环,然后随便一种数据结构维护。C:两个点等价,当且仅当以两个点为根的树同构。如果存在一个点不与其它点等价,则以这个点作为根,否则一定有两个连有边的点等价,断开这条边形成两棵同构的子树。经过这步处理之后,等价的点一定在相同深度。状态采用一般的树......
  • CF618C Constellation 题解
    题意描述给定\(n\)个点(\(n\leq10^5\)),找到三个点满足这三个点不在同一直线上且三个点构成的三角形中不包含其他点,保证所有点不会在同一直线上。题目分析首先必然每一个点都可以作为一组解中的点。不妨其中一个点编号为\(1\)。找一个点作为第二个点,为了使没有点在这条边上,这......
  • P5618 SDOI2015 道路修建题解
    题目分析虽然数据范围只有\(n\le60000\),但是完全可以直接用线段树做。首先考虑那种状态的图在左边和右边加入节点和边之后可以连通。容易发现,这种图有这两个性质:至少有一条路径,经过最左端和最右端中的点。所有点至少和最左端和最右端的点连通。于是可以划分成以下几种状态......
  • P7618 [COCI2011-2012#2] FUNKCIJA 题解
    看起来比较复杂,但实际上是一个树上dp的模型。因为每一重循环都最多有一个依赖,可以转化为树上的父子关系,于是就形成了一个森林。对于非叶子节点,设\(f_{u,i}\)表示第\(u\)循环变量的值是\(i\)时所有直接或间接依赖于它的循环变量(即以它为根的子树除开它的部分)循环次数,对非......
  • ARC170F Edge Deletion 2
    某人竟然忘记了星期天晚上有\(\text{ARC}\),我不说是谁。首先选择最小点删除和最小字典序都是最小化,所以可以弱化最小点删除的限制,现在原问题就变成了可以删除任意一个点的出边,如果没有出边则为\(0\)(这个其实本题中是最优的策略)。如果每一个点向其删除的出边连边,先考虑它会形......
  • AT_arc170_d Triangle Card Game
    当Alice先出了一张牌\(A\),Bob又出了一张\(B\),分类讨论一下。当\(B\leqA\),如果Alice不再出一张\((A-B,A+B)\)中的牌Bob就赢了,所以这种情况Bob会出最小的牌。当\(B>A\),如果Alice不再出一张\((B-A,B+A)\)中的牌Bob就赢了,这时无法贪心,对每个\(B_i\)考虑,找到......
  • CF-1831-E-卡特兰数+异或哈希+差分
    1831-E题目大意给定一个整数\(n\),和\(k\)个区间,区间端点范围在\([1,n]\)内。如果有一个长为\(n\)合法的括号序列,且它的这\(k\)个区间\([l,r]\)中的子括号序列也是合法的,那么称这个括号序列是“好的”。请你求出有多少个长度为\(n\)的“好的”括号序列,答案对\(998244353\)取模......
  • G2303、G2318期末复习习题册第四章解答(课本部分)
    ......
  • G2303、G2318期末复习习题册第四章解答(习题部分)
    ......
  • 【赛后反思】【LGR-172-Div.4】洛谷入门赛 #19 赛后反思
    【LGR-172-Div.4】洛谷入门赛#19赛后反思今日推歌:Cagayake《無名のエヌ(feat.重音テト&可不)》不正解だ不正解だった中途半端な身体は不是很火的一首歌,连个翻译都没有(悲Before最后5minAK了,第一次AK,虽然是入门赛但还是很有成就感的:省流:STL大胜利A分饼干I......