Search

How to Install Binary Clang on Any GNU/Linux Distro

For clang, clang++ and several others including LLVM.


How to Install Binary Clang on Any GNU/Linux Distro


Clang is a front-end compiler for the languages C, C++ , Objective-C and Objective-C++ that uses LLVM as a backend .

It aims to be another alternative to GCC, the GNU set of compilers .


Installation

Download the latest version here, the package name should be: clang+llvm-<VERSION>-x86_64-linux-gnu-ubuntu- 18.04.tar.xz (despite having the name ubuntu and an old version, it works for any distro), according to the publication date of this article, the most recent version is 15.0.6, example:

The package has several binaries, including clang and clang++

wget https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.6/clang+llvm-15.0.6-x86_64-linux-gnu-ubuntu-18.04.tar.xz

Extract:

tar xJf clang+llvm-15.0.6-x86_64-linux-gnu-ubuntu-18.04.tar.xz

Move to /opt renaming to directory with shorter name, example: clang

sudo mv clang+llvm-15.0.6-x86_64-linux-gnu-ubuntu-18.04/ /opt/clang

Export to your $PATH

echo 'export PATH="${PATH}:/opt/clang/bin"' | sudo tee -a /etc/profile
source /etc/profile

Test:

vim main.cpp

#include <iostream>

int main( int argc , char **argv ){
   std::cout << "Hello, World!\n";
   return 0;
}

Compile:

clang++ main.cpp

Enjoy and count this new installation to your GNU Glibc by doing the following:

  • 01. Create a file named libs.conf and enter the lib path to it:

    vim libs.conf

And paste the path below into that file:

/opt/clang/lib
  • 02. Save and move to the new libs directory:
sudo mv libs.conf /etc/ld.so.conf.d/
  • 03. Read everything:
sudo ldconfig

And be happy! 😃

Mainly you who use Gentoo and NO will need to compile Clang every time there is a new version!!! It takes time pakas! 😛


llvm clang cpp clanguage


Share



Comments