How to Install LLVM 6 on Ubuntu 17.04
To Install LLVM 6 on Ubuntu 17.04
LLVM is a C/C++ compiler toolset just like GCC. LLVM can compile C, C++ and Objective-C. LLVM is available on Linux, Windows and Mac OS X. So it’ s cross platform. You can either download LLVM source code and compile it yourself or download and use the pre-built binaries. It is really so simple to install LLVM on Ubuntu 17.04, and this tutorial covers the ground on the same process.
Installing LLVM 6
First go to the official website of LLVM package repository, since we use Ubuntu 17.04, so choose the following.
deb http://apt.llvm.org/zesty/ llvm-toolchain-zesty-6.0 main
Now go to the Application Menu and search for ‘ update’ . You should see something like this. Click on the “ Software & Updates” icon.
Now click on the “ Other Software” tab
Now click on “ Add” button.
Here paste the APT line that you copied a while ago from http://apt.llvm.org, and click on the Add Source button.
And give the password to complete the authentication.
And then close all the windows.
Now open a Terminal (Ctrl+Alt+T on Ubuntu) and run the following command to add the GPG key of LLVM.
root@linuxhelp:~# wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
--2018-01-28 03:10:59-- https://apt.llvm.org/llvm-snapshot.gpg.key
.
.
2018-01-28 03:11:00 (12.7 MB/s) - written to stdout [3145/3145]
OK
The GPG key has been added.
Now update the package repository cache with the following command
root@linuxhelp:~# apt-get update
Ign:1 cdrom://Ubuntu 17.04 _Zesty Zapus_ - Release amd64 (20170412) zesty InRelease
Hit:2 cdrom://Ubuntu 17.04 _Zesty Zapus_ - Release amd64 (20170412) zesty Release
.
Fetched 18.4 kB in 1s (10.1 kB/s)
Reading package lists... Done
Now you can install LLVM Clang and LLDB. To install Clang and LLDB only, run the following command:
root@linuxhelp:~# apt-get install clang-6.0 lldb-6.0 lld-6.0
Reading package lists... Done
Building dependency tree
.
.
Processing triggers for libc-bin (2.24-9ubuntu2.2) ...
Once the installation is complete, you can run the following command to test whether LLVM Clang is working or not.
root@linuxhelp:~# clang-6.0 --version
clang version 6.0.0-svn322567-1~exp1 (branches/release_60)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Now lets try compiling a C program using Clang
root@linuxhelp:~# vim test.c
#include < stdio.h>
int main(){
printf(" Hello World
" )
return 0
Lets now compile, the output will come.
root@linuxhelp:~# clang-6.0 test.c -0 test_c_code
root@linuxhelp:~# ./test_c_code
Hello World
Now we have compiled and run a C program Using LLVM. With this this tutorial comes to an end.
Comments ( 0 )
No comments available