How to install Clang and LLVM 3.9 on CentOS 7

2020-05-19 02:43发布

I have taken rpm packages from https://copr-be.cloud.fedoraproject.org/results/alonid/llvm-3.9.0/epel-7-x86_64/00505197-clang-3.9.0/ for Clang 3.9.

I am installing the rpm packages by the command

rpm -ivh clang-3.9.0-3.9.0-3.1.el7.centos.alonid.src.rpm

But when I do

rpm -ivh clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64.rpm

I get the following error :

error: Failed dependencies:
    clang-3.9.0-libs(x86-64) = 3.9.0-3.1.el7.centos.alonid is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64
    libLLVM-3.9.so()(64bit) is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64
    libclang.so.3.9()(64bit) is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64
    libclangAST.so()(64bit) is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64
    libclangBasic.so()(64bit) is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64
    libclangCodeGen.so()(64bit) is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64
    libclangDriver.so()(64bit) is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64
    libclangFormat.so()(64bit) is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64
    libclangFrontend.so()(64bit) is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64
    libclangFrontendTool.so()(64bit) is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64
    libclangIndex.so()(64bit) is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64
    libclangRewrite.so()(64bit) is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64
    libclangRewriteFrontend.so()(64bit) is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64
    libclangStaticAnalyzerFrontend.so()(64bit) is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64
    libclangTooling.so()(64bit) is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64
    libclangToolingCore.so()(64bit) is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64

Where should I install all these dependencies from?

标签: clang llvm
5条回答
爱情/是我丢掉的垃圾
2楼-- · 2020-05-19 03:08

A complete installation process is provided by Red Hat, please refer to Red Hat documents.

查看更多
戒情不戒烟
3楼-- · 2020-05-19 03:10

There was a much easier way to achieve this:

Add the Alonid's repo to /etc/yum.repos.d/epel.repo (assuming you have epel repo installed)

echo "[alonid-llvm-3.9.0]
name=Copr repo for llvm-3.9.0 owned by alonid
baseurl=https://copr-be.cloud.fedoraproject.org/results/alonid/llvm-
3.9.0/epel-7-$basearch/
type=rpm-md
skip_if_unavailable=True
gpgcheck=1
gpgkey=https://copr-be.cloud.fedoraproject.org/results/alonid/llvm-
3.9.0/pubkey.gpg
repo_gpgcheck=0
enabled=1
enabled_metadata=1" >> /etc/yum.repos.d/epel.repo

Then just sudo yum install clang-3.9.0

查看更多
何必那么认真
4楼-- · 2020-05-19 03:22

I am the author of the RPM repository you mention.

Follow from the main Copr page of the repository:

https://copr.fedorainfracloud.org/coprs/alonid/llvm-3.9.0/

If you have any question, you can contact me from there. Thanks!

查看更多
▲ chillily
5楼-- · 2020-05-19 03:28

Just open your link and look around, also go one level higher and find all necessary .rpm's. The following sequence worked for me:

yum install compiler-rt-3.9.0-3.9.0-3.el7.centos.alonid.x86_64.rpm
yum install clang-3.9.0-libs-3.9.0-3.1.el7.centos.alonid.x86_64.rpm
yum install clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64.rpm
yum install llvm-3.9.0-libs-3.9.0-7.el7.centos.alonid.x86_64.rpm
yum install llvm-3.9.0-3.9.0-7.el7.centos.alonid.x86_64.rpm
yum install llvm-3.9.0-devel-3.9.0-7.el7.centos.alonid.x86_64.rpm

By just doing yum install without any flags Clang and LLVM will be installed to /opt/llvm-3.9.0:

$ ls -l /opt/llvm-3.9.0 
total 12
drwxr-xr-x 2 root root 4096 Jun  3 23:48 bin
drwxr-xr-x 3 root root 4096 Jun  3 23:23 include
drwxr-xr-x 3 root root 4096 Jun  3 23:27 lib64

Also notice that there are other packages like -devel, -static, -debuginfo.

Useful tip: Without installing -devel packages you only get bin and lib64 folders where only the executables like bin/clang and libraries like lib64/libLLVM-3.9.0.so are located. If you also want to develop something with LLVM/Clang you will need corresponding -devel packages. Then you will also get include/ folder with headers.

By the way, thanks to the maintainers of this repo. Nice to have LLVM 3.9 out of the box.

查看更多
\"骚年 ilove
6楼-- · 2020-05-19 03:30

By enabling the SCL repository you can install Clang 5.0.1 on CentOS 7 using the llvm-toolset-7 package.

$ sudo yum install centos-release-scl
$ sudo yum install llvm-toolset-7

Enable llvm-toolset-7:

$ scl enable llvm-toolset-7 bash

You can now check you clang version with:

$ clang --version

See this Red Hat blog post for more information.

For more information about SCL, see this page.

查看更多
登录 后发表回答