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.

Answer from johnthagen on Stack Overflow
🌐
jdhao's digital space
jdhao.github.io › 2021 › 07 › 03 › install_clangd_on_linux
Install LLVM/Clangd from Source on CentOS 7 · jdhao's digital space
June 22, 2022 - -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra": it specifies which targets we want to build. To use clangd and clang-tidy, clang-tools-extra is a must. -DCMAKE_INSTALL_PREFIX=~/tools/llvm: it specifies where we want to install llvm, in this case, we install it under ~/tools/llvm.
🌐
Linux Hint
linuxhint.com › install_llvm_centos7
How to Install LLVM on CentOS7 – Linux Hint
The easiest way to install C and C++ libraries for LLVM Clang is to install gcc and g++ on CentOS 7.
🌐
Softwarecollections
softwarecollections.org › en › scls › rhscl › llvm-toolset-7.0
Clang and LLVM Toolset 7.0 — Software Collections
... # 1. Install a package with repository for your system: # On CentOS, install package centos-release-scl available in CentOS repository: $ sudo yum install centos-release-scl # On RHEL, enable RHSCL repository for you system: $ sudo yum-config-manager --enable rhel-server-rhscl-7-rpms # 2.
🌐
TecAdmin
tecadmin.net › installing-clang-on-centos
Step-by-Step Guide to Installing Clang on CentOS & Fedora – TecAdmin
April 26, 2025 - Before installing Clang, ensure your system meets the following requirements: A running instance of CentOS (7, 8 or 9) or Fedora (any recent version).
🌐
Nan Xiao's Blog
nanxiao.me › home › technology › how to install clang on centos 7
How to install clang on CentOS 7 | Nan Xiao's Blog
June 10, 2015 - The EPEL repository provides clang RPM package. So to install clang on CentOS 7, You need to installEPEL first: sudo yum install epel-release Then you can install clang: sudo yum install clang After this, you can use clang to compile your program. (You can also read this post on itechlounge.net)
🌐
GitHub
gist.github.com › liweitianux › 90f900c9a4565d0135851d8a473bd9bc
Build Clang 13 on CentOS 7 · GitHub
$ . /opt/rh/devtoolset-11/enable $ cmake3 -S llvm -B build -G 'Unix Makefiles' \ -DLLVM_ENABLE_PROJECTS='clang;lld' \ -DCMAKE_BUILD_TYPE=Release $ cmake3 --build build -j8
Find elsewhere
🌐
Reddit
reddit.com › r/llvm › is it possible to install clangd on centos 7 ?
r/LLVM on Reddit: Is it possible to install Clangd on CentOS 7 ?
November 23, 2022 -

--- UPDATE ---

I now have :

  • gcc (GCC) 7.1.0 (built from sources)

With it and cmake3 I can now try to build Clangd but I get an error during the make -j 8.

Details of the error can be found in this comment but the takeaway is :

[  6%] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/Process.cpp.o
	In file included from /home/kavan/Downloads/llvm-project/llvm/lib/Support/Process.cpp:107:0:
	/home/kavan/Downloads/llvm-project/llvm/lib/Support/Unix/Process.inc: Dans la fonction membre statique « static std::error_code llvm::sys::Process::FixupStandardFileDescriptors() »:
	/home/kavan/Downloads/llvm-project/llvm/lib/Support/Unix/Process.inc:209:54: error: initialisation invalide pour une référence du type « int (&)(int, stat*) noexcept » à partir d'une expression de type « int(int, stat*) noexcept »
	     if (RetryAfterSignal(-1, ::fstat, StandardFD, &st) < 0) {
		                                              ^
	In file included from /home/kavan/Downloads/llvm-project/llvm/lib/Support/Unix/Unix.h:23:0,
		         from /home/kavan/Downloads/llvm-project/llvm/lib/Support/Unix/Process.inc:13,
		         from /home/kavan/Downloads/llvm-project/llvm/lib/Support/Process.cpp:107:
	/home/kavan/Downloads/llvm-project/llvm/include/llvm/Support/Errno.h:32:23: note: dans le passage de l'argument 2 de « decltype(auto) llvm::sys::RetryAfterSignal(const FailT&, const Fun&, const Args& ...) [avec FailT = int; Fun = int(int, stat*) noexcept; Args = {int, stat*}] »
	 inline decltype(auto) RetryAfterSignal(const FailT &Fail, const Fun &F,
		               ^~~~~~~~~~~~~~~~
	make[2]: *** [lib/Support/CMakeFiles/LLVMSupport.dir/Process.cpp.o] Erreur 1
	make[1]: *** [lib/Support/CMakeFiles/LLVMSupport.dir/all] Erreur 2
	make: *** [all] Erreur 2

Any help is welcome.

--- END UPDATE ---

CentOS 7 is required for my work, usually I use Neovim with Clangd to develop.

Here are the version of some programs that could be of use :

  • gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)

  • GNU Make 3.82

  • cmake3 version 3.17.5

  • cmake version 2.8.12.2

  • clang version 3.4.2 (tags/RELEASE_34/dot2-final)

Clangd isn't in the yum repos (although clang version 3.4.2 is).

I tried installing clangd via snap, but clangd --version just never gives the prompt back without printing anything (Ctrl-C needed to get the prompt back).

I tried building it from source, but gcc isn't recent enough :

CMake Error at cmake/modules/CheckCompilerVersion.cmake:37 (message):
  Host GCC version must be at least 7.1, your version is 4.8.5.

Has anyone been in this situation before ?

🌐
Itechlounge
itechlounge.net › home › 2015 › june › linux : how to install clang on centos 7
Linux : How to install clang on CentOS 7 | ITechLounge.net
June 8, 2016 - The EPEL repository provides clang RPM package. So to install clang on CentOS 7, You need to install EPEL first:
🌐
Red Hat
developers.redhat.com › blog › 2018 › 07 › 07 › yum-install-gcc7-clang
How to install Clang/LLVM 5 and GCC 7 on RHEL | Red Hat Developer
November 1, 2023 - Become root. Enable the rhscl, devtools, and optional software repos. Add the Red Hat Developer Tools key to your system · Use yum to install devtoolset7 (GCC 7) and llvm-toolset-7 (Clang 5).
🌐
Centos
lists.centos.org › hyperkitty › list › discuss@lists.centos.org › thread › WGJDZLUKKATX4D6527VMDAIIULOKZCVD
How to install clang on CentOS 7? - Discuss - lists.centos.org
[root@hp ~]# yum install clang Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: centos.mia.host-engine.com * elrepo: elrepo.mirrors.arminco.com * extras: centos.arvixe.com * updates: centos.eecs.wsu.edu No package clang available.
🌐
Installati.one
installati.one › home › how to install clang on centos 7
How To Install clang on CentOS 7 | Installati.one
May 1, 2023 - In this tutorial we learn how to install clang on CentOS 7 using yum and dnf.
🌐
CentOS FAQ
centosfaq.org › home › how to install clang on centos 7?
How To Install Clang On CentOS 7?
June 8, 2015 - all,I want to install clang on CentOS 7. After executing yum install clang, it outputs:[root@hp ~]# yum install clang Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: CentOS.mia.host-engine.com * elrepo: elrepo.mirrors.arminco...Read more
🌐
Red Hat
developers.redhat.com › blog › 2019 › 03 › 05 › yum-install-gcc-8-clang-6
How to install GCC 8 and Clang/LLVM 6 on Red Hat Enterprise Linux 7 | Red Hat Developer
November 1, 2023 - Under your normal user ID, run scl enable to add devtoolset-8 and llvm-toolset-6.0 to your path(s). Optional: Permanently enable GCC 8 and Clang 6 by adding scl_source to your .bashrc.