The objective is to install GCC the C compiler on Ubuntu 20.04 LTS Focal Fossa Linux.

In this tutorial you will learn:
  • How to install GCC compiler
  • How to Check C compiler version
  • How to Compile basic C program from source code
  • How to run C compile C program

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Installed or upgraded Ubuntu 20.04 Focal Fossa
Software GCC
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ - requires given linux commands to be executed as a regular non-privileged user

install GCC the C compiler on Ubuntu 20.04 step by step instructions

Although you can install the C compiler separately by installation of the gcc package, the recommended way to install the C compiler on Ubuntu 20.04 is by installation of the entire development package build-essential.

  1. Install C compiler by installation of the development package build-essential:
    $ sudo apt install build-essential
    
  2. DO YOU NEED MULTIPLE C AND/OR C++ COMPILER VERSIONS?
    Visit "How to switch between multiple GCC and G++ compiler versions on Ubuntu 20.04" to see how to install multiple compiler versions on the same Ubuntu system.
  3. Check C compiler version:
    $ gcc --version
    gcc (Ubuntu 9.2.1-17ubuntu1) 9.2.1 20191102
    

  4. SUBSCRIBE TO NEWSLETTER
    Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


  5. Create a basic C code source. For example let's create hello world C program. Save the following code as hello.c text file:
    #include <stdio.h>
    int main()
    {
       printf("Hello, World!");
       return 0;
    }
    
  6. Compile and execute the hello.c C code:
    $ gcc -o hello hello.c 
    $ ./hello 
    Hello, World!
    
ARE YOU LOOKING FOR A LINUX JOB?
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed on LinuxCareers.com.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.