5

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.

J-A-Brown
  • 85
  • 1
  • 3
  • 9

3 Answers3

5

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.

user2864740
  • 60,010
  • 15
  • 145
  • 220
  • `apt install` generated the message "0 upgraded, 0 newly installed, 0 to remove and 295 not upgraded." `llvm-cov` is version 9.0.0 dated Sept 19. – J-A-Brown Dec 02 '19 at 22:25
  • @J-A-Brown `apt install clang-9`? That will either successfully install clang-9, report it's already installed (yay!), or report a useful error. The LLVM page recommends a number of core packages; adapt to needs. The error message in the post ("Unable to locate package clang-9") is due to mis-configured sources or non-updated cache. – user2864740 Dec 02 '19 at 22:29
  • I was able to generate code coverage using the gcc compiler. I was satisfied with that solution. – J-A-Brown Dec 03 '19 at 19:56
2
                            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
  • I downloaded `clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz` and extracted it. Even in its `bin` folder running `clang --version` shows 3.8.0. Running `./clang --version` shows 9.0.0. What got missed? – J-A-Brown Oct 16 '19 at 13:07
  • @J-A-Brown `./clang` is executable in current directory, without `./` another executable from `PATH` – Godin Oct 25 '19 at 18:23
  • I did this for clang-10. I am getting this error: /usr/bin/ld.gold: error: cannot find -lLLVMExtensions – dfordevy Jan 12 '21 at 17:35
2

Here are the commands for LLVM 9:

wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
sudo apt-get update
sudo apt-get install clang-9 libclang-9-dev llvm-9-dev
soham
  • 1,508
  • 6
  • 30
  • 47