How to install Clang and LLVM 3.9 on CentOS 7

I took 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 install rpm packages with 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 am getting 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

      

How do I install all these dependencies?

+7


source to share


5 answers


With the SCL repository enabled, you can install Clang 5.0.1 on CentOS 7 using the package . llvm-toolset-7

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

      

Include llvm-toolset-7

:

$ scl enable llvm-toolset-7 bash

      



Now you can check your clang version:

$ clang --version

      

See this post on the Red Hat blog for more information.

For more information on SCL, see this page .

+19


source


There was a much simpler way to achieve this:

Add the Alonid repository 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

+5


source


I am the author of the RPM repository you mentioned.

Follow from Copr repository homepage:

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

If you have any questions, you can contact me from there. Thank!

+5


source


Just open your link and look around, also go one level up and find all you need .rpm

. 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 simply doing yum install

without any flags, Clang and LLVM will be set 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 note that there are other packages, such as -devel

, -static

, -debuginfo

.

Helpful Hint: Without installing packages, -devel

you only get folders bin

and lib64

where only executables are located, such as bin/clang

libraries such as lib64/libLLVM-3.9.0.so

. If you also want to develop with LLVM / Clang, you will need the corresponding packages -devel

. Then you will also get a folder include/

with headers.

By the way, thanks to the developers of this repo. It's nice to have LLVM 3.9 out of the box.

+1


source


Red Hat provides a complete installation process, see Red Hat docs .

+1


source







All Articles