LLVM 安装教程
环境:ubuntu16.04 llvm-4.0 clang-4.0
步骤:
1.依赖库安装
$ sudo apt-get install build-essential curl libcap-dev git cmake libncurses5-dev python-minimal python-pip unzip
2.安装LLVM 需要注意:
对于不同版本的ubuntu应该到 LLVM Package Repository 找到对应版本的。写入source.list 中。
以16.04 为例:
deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-4.0 main
deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial-4.0 main
添加repository key并下载llvm 3.9的packages
$ wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key|sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get install clang-4.0 libclang-common-4.0-dev libclang-4.0-dev libclang1-4.0 libclang1-4.0-dbg libllvm-4.0-ocaml-dev libllvm4.0 libllvm4.0-dbg lldb-4.0 llvm-4.0 llvm-4.0-dev llvm-4.0-runtime clang-format-4.0 python-clang-4.0 libfuzzer-4.0-dev
注意这个时候/usr/bin/clang-4.0是在PATH里面,为了使用clang以及其他不带4.0后缀的版本 ,需要在~/.bashrc里面改一下PATH:(注意不要在命令行中配置,否则每次开机都得配置一遍)
export PATH="/usr/lib/llvm-4.0/bin:$PATH"
至此,已经可以使用clang进行测试。
这里有个问题,如果出现以下错误,是libwinpr-synch0.1在上次安装过程中失败的原因,需要重新安装。
dpkg: error processing package libwinpr-synch0.1:amd64 (--configure):
package libwinpr-synch0.1:amd64 is not ready for configuration
重新安装使用以下命令:
sudo apt-get --reinstall install libwinpr-synch0.1
如果sources.list一直不能更新的话,替换原来的源,将其改为aliyun(亲测可行)。
使用点sources.list文件如下:
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
#deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial main
#deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial main
# 4.0
deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-4.0 main
deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial-4.0 main