Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot install llvm-9 or clang-9 on Ubuntu 16.04

I have not been able to install either llvm version 9 or clang version 9 on Ubuntu. We have installed them on Windows.

I have tried a command and saw this response.

sudo apt-get install llvm-9
Reading package lists... Done
Building dependency tree
Reading state information...
Done E: Unable to locate package llvm-9

I have also tried and saw this response.

sudo apt-get install clang-9
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package clang-9

My /etc/apt/sources.list file contains

deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-9.0 main

I found the website and saw that the folder was llvm-toolchain-xenial-9. Trying that version did not work either.

What else can I do?

I have looked at downloading the binaries but am not sure what installation steps I might be missing. I am not interested in compiling source code.

like image 378
J-A-Brown Avatar asked Mar 03 '23 08:03

J-A-Brown


2 Answers

The Clang/LLVM project provides Nightly build packages for Ubuntu and Debian.

See the https://apt.llvm.org

The goal is to provide Debian and Ubuntu [Clang and LLVM] packages ready to be installed with minimal impact on the distribution. Packages are available for amd64 and i386 (except for recent Ubuntu) and for both the stable, old-stable and development branches (currently 8, 9 and 10).

Packages are built using stage2 and extremely similar to the one shipping in Debian & Ubuntu.

To use:

  • Add the appropriate repositories to the /etc/apt/sources.list file; there are distinct repos for different Debian and Ubuntu versions.
  • Add the apt key (shown in the link).
  • Run an apt update to refresh the cache.
  • Add packages with apt install clang-9 (or other package as desired).

If something "did not work" using the vetted package system, diagnose that issue directly. Xenial has Clang/LLVM 9 packages, and I've recently installed the packages into Disco.

The described symptom ("Unable to locate package") sounds as though one neglected to run apt update, in which case the packages from the newly-added sources would not be visible to apt. This is a tool-usage issue, not a lack of available packages.

like image 94
user2864740 Avatar answered Apr 10 '23 00:04

user2864740


                            LLVM INSTALLATION STEPS
                            -----------------------

LLVM Compiler Prerequisites:

    OPERATING SYSTEM    :   Ubuntu 16.04 LTS

    RAM                 :   Minimum 16GB to 32GB

    SWAP MEMORY         :   Minimum 10GB to 20GB

    MEMORY  NEEDED      :   Minimum 70GB

Install CMake version 3.5.1:

    $sudo apt install cmake

LLVM Compiler Installation Steps

Step1: #download llvm from https://github.com/llvm/llvm-project/releases/download/llvmorg-8.0.1/llvm-8.0.1.src.tar.xz

#download clang from https://github.com/llvm/llvm-project/releases/download/llvmorg-8.0.1/cfe-8.0.1.src.tar.xz

#extract files into folders:
            tar -xf cfe-8.0.1.src.tar.xz
            tar -xf llvm-8.0.1.src.tar.xz

#change directory names to llvm8 and clang

            mv cfe-8.0.1.src clang

mv llvm-8.0.1.src llvm8

Step2 : #change present working directory to llvm_source_directory here it is llvm8

$cd llvm8

##create build directory

$mkdir build

##change pwd to build directory

$cd build

#Build (PATH =/llvm8/build) 

#execute following command in build directory:

$cmake -DLLVM_ENABLE_PROJECTS=clang -G "Unix Makefiles" ../

Step3: #execute make command in pwd:

/llvm8/build$ make

Step4 : #after 100% of linking process execute following command in build directory:

$sudo make install

$ sudo reboot

step5 : #after installation restart your system!

#for checking llvm installation type

$llvm-config --version      #it shows 8.0.1

$clang --version            #it shows 8.0.1
like image 32
glow compiler Avatar answered Apr 10 '23 01:04

glow compiler