OS: Ubuntu 18.04
There are already some posts about how to install clang
in Ubuntu, however many of them are out of date, and my question is specific to installing clang as part of the insallation of YouCompleteMe.
First, following the indications in this answer and in the link provided there, I ran these commands:
$ wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
$ sudo apt-get update && sudo apt-get upgrade
$ sudo apt-add-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main"
I then ran $ vim /etc/apt/sources.list
and could verify that the new lines corresponding to llvm
were added, as expected. I then ran:
$ apt-get install clang-8 lldb-8 lld-8 --print-uris
to get the information about disk space needed, which in this case was:
The following NEW packages will be installed:
binfmt-support clang-8 lib32gcc1 lib32stdc++6 libc6-i386 libclang-
common-8-dev libclang1-8 libffi-dev liblldb-8 libobjc-7-dev libobjc4
libomp-8-dev libomp5-8 libpfm4 libpython-stdlib lld-8 lldb-8
llvm-8 llvm-8-dev llvm-8-runtime python python-lldb-8 python-minimal
python-six python2.7 python2.7-minimal
0 upgraded, 26 newly installed, 0 to remove and 0 not upgraded.
Need to get 71,4 MB of archives.
After this operation, 412 MB of additional disk space will be used.
Now, before actually installing those packages, I read again the README file of YouCompleteMe, and noticed it says:
You can use the system libclang or clangd only if you are sure it is version 8.0.0 or higher, otherwise don't. Even if it is, we recommend using the official binaries from llvm.org if at all possible. Make sure you download the correct archive file for your OS.
We STRONGLY recommend AGAINST use of the system libclang or clangd instead of the upstream compiled binaries. Random things may break. Save yourself the hassle and use the upstream pre-built libclang or clangd.
I guess that when they say "the system libclang", they refer to the libclang
I was going to install using apt-get
(Is this what they actually refer to? If someone knows what they mean by "system libclang", please let me know). So, I decided to follow the LLVM link provided by them. Once there, I clicked on "Ubuntu 18.04" under the section "Pre-built binaries". Then the download of the tar.xz
file started, and I then ran:
$ tar -xJf clang*.tar.xz
And this post implies I should run:
$ cd clang*
$ sudo cp -R * /usr/local/
So now I see that I have two ways of installing clang: through apt-get
, and by unpacking the binary.
Is YouCompleteMe asking for an unusual way of installing clang
?
What is the right way to install clang
in Ubuntu 18.04?
sudo apt install clang-8
) doesn't work with YouCompleteMe and instead they recommend installing their own pre-built binaries.sudo apt install clang-8 libclang1-8