使用 WSL Ubuntu 安装 LLVM 9

使用 WSL Ubuntu 安装 LLVM 9

我正在尝试使用页面中的脚本安装最新的稳定版本:
https://apt.llvm.org/

但是我遇到了以下错误:

Reading package lists... Done
+ apt-get install -y clang-9 lldb-9 lld-9 clangd-9
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 lldb-9 : Depends: llvm-9-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

之前还有其他事情要做吗?我之前已经安装了 LLVM 8,没有任何错误。

答案1

我相信您可以找到更多信息: https://solarianprogrammer.com/2017/12/13/linux-wsl-install-clang-libcpp-compile-cpp-17-programs/ 刚刚完成了本文中描述的整个处理过程,效果非常好。希望对您有所帮助。

编辑:如下所述,以下是本教程中描述的关键步骤:

更新apt:

sudo apt update

sudo apt upgrade

安装运行 clang/llvm 的依赖项:

sudo apt install build-essential xz-utils curl

下载针对您目标 Linux 发行版的二进制文件(在项目网站上查找您想要的“名称”或直接使用最新版本):

curl -SL http://releases.llvm.org/9.0.0/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz | tar -xJC .

mv clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-18.04 clang_9.0.0

sudo mv clang_9.0.0 /usr/local

将二进制文件添加到 PATH: export PATH=/usr/local/clang_9.0.0/bin:$PATH

export LD_LIBRARY_PATH=/usr/local/clang_9.0.0/lib:$LD_LIBRARY_PATH

相关内容