Install LLVM on Ubuntu

Chưa phân loại

Install LLVM 5 on Ubuntu 17.10 Artful Aardvark

LLVM is a C/C++ compiler toolset just like GCC. LLVM can compile C, C++ and Objective-C. Clang provided by the LLVM toolset is able to compile C and C++ codes faster than GCC. The LLVM debugger LLDB is much more memory efficient and very fast at loading symbols compared to GCC. LLVM supports C++11, C++14 and C++17 through libc++ and libc++ ABI projects.

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. For more information on LLVM, check out the official website of LLVM at

In this article, I will show you how to install LLVM 5 on Ubuntu 17.10 Artful Aardvark. I will use the LLVM official Ubuntu package repository to install LLVM on Ubuntu 17.10. Let’s get started.

First go to the official website of LLVM package repository at  This website contains repository information that you can use to configure apt on Ubuntu and Debian.

We will use Ubuntu 17.10 in this article as I stated earlier. So scroll down a little bit and you should find the following lines as shown in the screenshot below. You can either install LLVM version 4 or version 5. I will pick LLVM 5. Copy the line with Ctrl+C

Now go to the Application Menu and search for ‘update’. You should see something like this. Click on the “Software & Updates” icon as shown in the screenshot below.

Software & Updates should open up.

Now click on the “Other Software” tab. You should see the following window.

Now click on “Add..” button.

You should see the following window.

Here paste the APT line that you copied a while ago from

It should look as follows once you’re done pasting the APT line. Now click on “Add Source” button as shown in the screenshot below.

You should be prompted for the user password. Type in your Ubuntu login password and click on “Authenticate”.

Once the APT line is added, “Software & Updates” should look as follows.

Now click on “Close” on “Software & Updates” window.

Now you should see the following window.  Click on “Close” button. “Reload” button won’t work right now. Because we haven’t added the GPG key yet. I feel like it is easier to do from the terminal.

Now open a Terminal (Ctrl+Alt+T on Ubuntu) and run the following command to add the GPG key of LLVM.

The GPG key has been added.

$ sudo wget -O –|sudo apt-key add

The GPG key has been added.

Now update the package repository cache with the following command:

$ sudo apt-get update

Now you can install LLVM Clang and LLDB.
To install Clang and LLDB only, run the following command:

$ sudo apt-get install clang-5.0 lldb-5.0 lld-5.0

Now press ‘y’ and press <Enter> to continue.

The package manager should download and install everything.

Once the installation is complete, you can run the following command to test whether LLVM Clang is working or not.

$ clang-5.0 –version

From the screenshot you can see that the installed clang version 5.0.1

Now I am going to write a simple C and C++ hello world program and try to compile it on LLVM Clang.

This is the C code I will try to compile with Clang 5.0.1

#include <stdio.h>
int main(){
printf("Hello Worldn");
return 0;

To compile C code with Clang 5.0.1, run the following code


Here I am compiling test.c source file and the output executable file will be test_ccode.
If there is any error in the source file, it will be reported. In my case, everything was okay.

Now I can run the compiled executable with the following command.

$ ./test_ccode

You can see that, I got the expected output.

Now I will compile the following C++ hello world source file.

#include <iostream>
using namespace std;
int main(){
cout << "Hello World" << endl;
return 0;

To compile C++ source file, run the following command:


Here test.cpp is the C++ source file that I am compiling and test_cpp is the exectable that will be generated as a result.
I got no errors, so the compilation was successful.

You can execute the program just like before:

$ ./test_cpp

You can see the output is just as expected.

So that’s how you install LLVM 5 from the LLVM official repository on Ubuntu 17.10 Artful Aardvark. Thanks for reading this article.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Hướng dẫn cấu hình bản ghi SPF, DKIM, DMARC nâng cấp bảo mật G Suite

Nhằm nâng cấp bảo mật của hệ thống G Suite trước các tình trạng email nặc danh (phishing email),...

How to build a Nodejs app on docker

Docker has become a hot topic of conversation nowadays especially among developers. So what is docker? Docker is an opensource...

Golang Strings

Strings package in Golang Overview In this lesson on String package in Golang, we will study various examples on managing...
Bài Viết

Bài Viết Mới Cập Nhật

Check proxy trên trang nào chuẩn nhất❓

Thuê Proxy chạy Google Ads / Cần chú ý gì khi chọn proxy và email chạy G.G ads?

Thuê proxy 4G ở đâu uy tín, giá rẻ, chất lượng?

Vì sao cần thuê proxy xoay? Địa chỉ cung cấp proxy xoay uy tín

Thuê proxy v6 kéo view Youtube ở đâu uy tín, chất lượng?