How to install clang on Ubunut?

In this video tutorial I will teach you how to install clang on Ubunut 15.10? We have used the command sudo apt-get install clang for installing clang.

How to install clang on Ubunut?

How to install clang on Ubunut?

In this tutorial I am showing you a video of installing clang on Ubunut 15.10 which explains you the command to install clang on your Ubunut box.

The clang is latest development and it many replace gcc in future. In this tutorial we have installed clang on Ubunut 15.10 desktop, but same process is applies to all the version of Ubunut operating system.

What is clang?

The clang is LLVM compiler which is designed to support many programming language. Currently clang supports  C, C++, Objective-C, and Objective-C++ language and compiles the code of these programming languages to machine language code.

Since clang is LLVM compiler it can generate core libraries for a number of CPUs using various optimization technologies.

Here is the video tutorial of "How to install clang on Ubunut?":

Here are the features of clang:

  • The clang is fast compiler and uses less memory
  • clang provides GCC compatibility
  • This is based on the modular library based architecture
  • It provides tight integration with the IDE
  • The clang is single unified parser/compiler for C, Objective C, C++, and Objective C++

How to check if clang?

If you type clang on the terminal window in Ubunut it will tell you weather clang is installed on not:

clang -version

The program 'clang' is currently not installed. You can install it by typing:
sudo apt-get install clang

How to install clang?

If you are using the Ubunut desktop then you can use the Ubuntu software center and find the clang and install.

In Ubuntu based server or even in desktop following command can be used to install clang:

sudo apt-get install clang

above command will install clang on Ubuntu, here is the output of the installation process:

deepak1@deepak1-VirtualBox:~$ clnag -version
No command 'clnag' found, did you mean:
 Command 'clang' from package 'clang' (universe)
clnag: command not found
deepak1@deepak1-VirtualBox:~$ clang -version
The program 'clang' is currently not installed. You can install it by typing:
sudo apt-get install clang
deepak1@deepak1-VirtualBox:~$ sudo apt-get install clang
[sudo] password for deepak1: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-headers-4.2.0-16 linux-headers-4.2.0-16-generic
  linux-image-4.2.0-16-generic linux-image-extra-4.2.0-16-generic
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  clang-3.6 libclang-common-3.6-dev libclang1-3.6 libffi-dev libobjc-5-dev
  libobjc4 libtinfo-dev llvm-3.6 llvm-3.6-dev llvm-3.6-runtime
Suggested packages:
  gnustep gnustep-devel clang-3.6-doc llvm-3.6-doc
The following NEW packages will be installed:
  clang clang-3.6 libclang-common-3.6-dev libclang1-3.6 libffi-dev
  libobjc-5-dev libobjc4 libtinfo-dev llvm-3.6 llvm-3.6-dev llvm-3.6-runtime
0 upgraded, 11 newly installed, 0 to remove and 66 not upgraded.
Need to get 43.6 MB of archives.
After this operation, 213 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://in.archive.ubuntu.com/ubuntu/ wily/main libobjc4 amd64 5.2.1-22ubuntu2 [111 kB]
Get:2 http://in.archive.ubuntu.com/ubuntu/ wily/main libobjc-5-dev amd64 5.2.1-22ubuntu2 [382 kB]
Get:3 http://in.archive.ubuntu.com/ubuntu/ wily/main libclang1-3.6 amd64 1:3.6.2-1 [3,698 kB]
Get:4 http://in.archive.ubuntu.com/ubuntu/ wily/main libclang-common-3.6-dev amd64 1:3.6.2-1 [701 kB]
Get:5 http://in.archive.ubuntu.com/ubuntu/ wily/universe clang-3.6 amd64 1:3.6.2-1 [24.8 MB]
Get:6 http://in.archive.ubuntu.com/ubuntu/ wily/universe clang amd64 1:3.6-26ubuntu1 [3,350 B]
Get:7 http://in.archive.ubuntu.com/ubuntu/ wily/main libtinfo-dev amd64 5.9+20150516-2ubuntu1 [77.2 kB]
Get:8 http://in.archive.ubuntu.com/ubuntu/ wily/main llvm-3.6-runtime amd64 1:3.6.2-1 [42.4 kB]
Get:9 http://in.archive.ubuntu.com/ubuntu/ wily/main llvm-3.6 amd64 1:3.6.2-1 [1,281 kB]
Get:10 http://in.archive.ubuntu.com/ubuntu/ wily/main libffi-dev amd64 3.2.1-3 [162 kB]
Get:11 http://in.archive.ubuntu.com/ubuntu/ wily/main llvm-3.6-dev amd64 1:3.6.2-1 [12.3 MB]
Fetched 43.6 MB in 3min 45s (193 kB/s)                                         
Selecting previously unselected package libobjc4:amd64.
(Reading database ... 260913 files and directories currently installed.)
Preparing to unpack .../libobjc4_5.2.1-22ubuntu2_amd64.deb ...
Unpacking libobjc4:amd64 (5.2.1-22ubuntu2) ...
Selecting previously unselected package libobjc-5-dev:amd64.
Preparing to unpack .../libobjc-5-dev_5.2.1-22ubuntu2_amd64.deb ...
Unpacking libobjc-5-dev:amd64 (5.2.1-22ubuntu2) ...
Selecting previously unselected package libclang1-3.6:amd64.
Preparing to unpack .../libclang1-3.6_1%3a3.6.2-1_amd64.deb ...
Unpacking libclang1-3.6:amd64 (1:3.6.2-1) ...
Selecting previously unselected package libclang-common-3.6-dev.
Preparing to unpack .../libclang-common-3.6-dev_1%3a3.6.2-1_amd64.deb ...
Unpacking libclang-common-3.6-dev (1:3.6.2-1) ...
Selecting previously unselected package clang-3.6.
Preparing to unpack .../clang-3.6_1%3a3.6.2-1_amd64.deb ...
Unpacking clang-3.6 (1:3.6.2-1) ...
Selecting previously unselected package clang.
Preparing to unpack .../clang_1%3a3.6-26ubuntu1_amd64.deb ...
Unpacking clang (1:3.6-26ubuntu1) ...
Selecting previously unselected package libtinfo-dev:amd64.
Preparing to unpack .../libtinfo-dev_5.9+20150516-2ubuntu1_amd64.deb ...
Unpacking libtinfo-dev:amd64 (5.9+20150516-2ubuntu1) ...
Selecting previously unselected package llvm-3.6-runtime.
Preparing to unpack .../llvm-3.6-runtime_1%3a3.6.2-1_amd64.deb ...
Unpacking llvm-3.6-runtime (1:3.6.2-1) ...
Selecting previously unselected package llvm-3.6.
Preparing to unpack .../llvm-3.6_1%3a3.6.2-1_amd64.deb ...
Unpacking llvm-3.6 (1:3.6.2-1) ...
Selecting previously unselected package libffi-dev:amd64.
Preparing to unpack .../libffi-dev_3.2.1-3_amd64.deb ...
Unpacking libffi-dev:amd64 (3.2.1-3) ...
Selecting previously unselected package llvm-3.6-dev.
Preparing to unpack .../llvm-3.6-dev_1%3a3.6.2-1_amd64.deb ...
Unpacking llvm-3.6-dev (1:3.6.2-1) ...
Processing triggers for man-db (2.7.4-1) ...
Processing triggers for install-info (6.0.0.dfsg.1-3) ...
Processing triggers for doc-base (0.10.6) ...
Processing 1 added doc-base file...
Registering documents with scrollkeeper...
Setting up libobjc4:amd64 (5.2.1-22ubuntu2) ...
Setting up libobjc-5-dev:amd64 (5.2.1-22ubuntu2) ...
Setting up libclang1-3.6:amd64 (1:3.6.2-1) ...
Setting up libclang-common-3.6-dev (1:3.6.2-1) ...
Setting up clang-3.6 (1:3.6.2-1) ...
Setting up clang (1:3.6-26ubuntu1) ...
Setting up libtinfo-dev:amd64 (5.9+20150516-2ubuntu1) ...
Setting up llvm-3.6-runtime (1:3.6.2-1) ...
Setting up llvm-3.6 (1:3.6.2-1) ...
Setting up libffi-dev:amd64 (3.2.1-3) ...
Setting up llvm-3.6-dev (1:3.6.2-1) ...
Processing triggers for libc-bin (2.21-0ubuntu4) ...
deepak1@deepak1-VirtualBox:~$ clang -version
clang: error: unknown argument: '-version'
clang: error: no input files
deepak1@deepak1-VirtualBox:~$ clang --version
Ubuntu clang version 3.6.2-1 (tags/RELEASE_362/final) (based on LLVM 3.6.2)
Target: x86_64-pc-linux-gnu
Thread model: posix
deepak1@deepak1-VirtualBox:~$ 
deepak1@deepak1-VirtualBox:~$ clang --version
Ubuntu clang version 3.6.2-1 (tags/RELEASE_362/final) (based on LLVM 3.6.2)
Target: x86_64-pc-linux-gnu
Thread model: posix
deepak1@deepak1-VirtualBox:~$ 

Check more Linux Tutorials.