Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install Clang and LLVM 3.9 on CentOS 7

Tags:

llvm

clang

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?

like image 875
Seetu Agarwal Avatar asked May 27 '17 16:05

Seetu Agarwal


People also ask

Does LLVM include Clang?

Clang is released as part of regular LLVM releases. You can download the release versions from https://llvm.org/releases/. Clang is also provided in all major BSD or GNU/Linux distributions as part of their respective packaging systems. From Xcode 4.2, Clang is the default compiler for Mac OS X.

How do I install the latest Clang?

Enter the command clang --version to see if the Clang compilers are already installed. If you want to install or update the Clang compilers, enter the command command xcode-select --install The following pop-up windout should appear on your screen (in this example I have placed it withing the Terminal window).

How do I run Clang on Linux?

You need to specify an input file after typing clang in the terminal in order to tell clang what code to run. This example uses the clang package from the default Ubuntu repositories (clang-3.8) and the following source code for hello.


2 Answers

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.

like image 162
phoenix Avatar answered Sep 18 '22 08:09

phoenix


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!

like image 33
Dan Aloni Avatar answered Sep 17 '22 08:09

Dan Aloni