# 安裝 LLVM toolchain II ## 前言 如果只是使用者,基本上可以不用自己從 source code 編譯,透過作業系統的軟體套件管理工具,就可從預設的安裝源下載 llvm, clang, clang-format, clangd 等工具。不過如想跟到最新版的 llvm toolchain 就需要自己設定 llvm 安裝源。 :::info - 作業系統以及對應的軟體套件管理系統 | OS | Package Manager | | ------- | ---------------- | | Linux | dpkg, Pacman ... | | Windows | Winget ... | | MacOs | Homebrew ... | [各種軟體套件管理命令列表](https://en.wikipedia.org/wiki/Package_manager#Comparison_of_commands) ::: 最近將 ubuntu 22.0 (jammy) 升級到 ubuntu 24.04 (noble),但問題出在更新 clang-format, clangd 等工具之後,因為沒有安裝對應版本的 `libLLVM.so` 導致無法執行(也有可能實際有裝但沒有建立對應的 symbolic link)。 > 升級 ubuntu 會導致之前設定在 `/etc/apt/source.list.d` 要自己再手動更新一次,連 [PPA](https://launchpad.net/ubuntu/+ppas) 來源也一樣,我自己都想換滾動式更新的作業系統。 ## [LLVM Debian/Ubuntu nightly packages](https://apt.llvm.org/) llvm 提供使用 apt 進行安裝的方式 (官方只有列出 debian 跟 ubuntu),只要在 `/etc/apt/source.list` 或 `/etc/apt/source.list.d` 目錄下設定好來源,在透過 apt 安裝即可。 ### 步驟一 兩種方式加入 llvm [fingerprint](https://en.wikipedia.org/wiki/Fingerprint_(computing)),不過... **[Ubuntu: apt-key is deprecated](https://medium.com/@glegoux/ubuntu-22-04-jammy-jellyfish-apt-key-is-deprecated-2dbbee8aec84)** ``` wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - ``` or ``` wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc ``` ### 步驟二 根據作業系統跟版本選擇對應的安裝來源 (ubuntu 24.04 noble)  我選擇 stable branch llvm-18,並將來源寫入 `source.list`  > [What's the difference between multiverse, universe, restricted and main?](https://askubuntu.com/q/58364) ### 步驟三 apt 更新後即可安裝想要的 llvm 工具 ```bash sudo apt update sudo apt install llvm clang lldb # just install whatever you want ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up