How do I install llvm-10 on Ubuntu 18.04?

Solution 1:

check how to install LLVM here https://apt.llvm.org/ to retrieve the archive signature like this:

wget --no-check-certificate -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -

Add the PPAs where to install from:

add-apt-repository 'deb http://apt.llvm.org/bionic/   llvm-toolchain-bionic-10  main'

Update packages:

sudo apt update

Install default llvm & llvm-config:

sudo apt install llvm

Install custom version: llvm-10 & llvm-config-10:

sudo apt-get install llvm-10 lldb-10 llvm-10-dev libllvm10 llvm-10-runtime

Use "update-alternatives" to config alternatives like this for "llvm-config":

sudo update-alternatives --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-6.0 6
sudo update-alternatives --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-10 10
sudo update-alternatives --config llvm-config

. . . and select: "1"

Selection Path Priority Status
* 0 /usr/bin/llvm-config-6.0 6 auto mode 0
1 /usr/bin/llvm-config-10 10 auto mode 1

Press <enter> to keep the current choice[*], or type selection number: 1

Solution 2:

I am on Mint 19.3, but this should also work for Ubuntu 18.04, which is what this Mint version is based on.

My solution was to specify the version to use specifically when installing:

sudo apt-get install llvm-10*

The reason to use the glob asterisk here is that some of the related packages are also needed for things to work, so merely installing the base package will not work (at least, not for pyod which when you try pip install gives you llvm-config: error: component libraries and shared library). This follow-up problem and solution was mentioned here.

After this, you need to change the llvm-config link because otherwise it still points to the 6.X version. This is done by (from here):

sudo -i
cd /usr/bin
rm llvm-config #if it exists already, which probably it does
ln -s llvm-config-10 llvm-config

The config now points to the correct version. Installing the 10 version does not update this pointer. After this, my pip command worked (i.e. pip install llvmlite, and after that, pip install pyod).