How To Install The Latest GCC On Ubuntu

GCC is the abbreviation of GNU Compiler Collection. It contains a set of compilers that can compile C, C++, Objective-C, etc language-coded programs. This article will tell you how to install the latest version of GCC on Linux OS, especially Ubuntu.

1. Check The Current GCC Version.

  1. Run the command gcc -version in a terminal, if you get the below output, it means GCC is not installed.
    $ gcc --version
    Command 'gcc' not found, but can be installed with:
    sudo apt install gcc

2. Install GCC On Ubuntu Steps.

  1. Run the command sudo apt update to make sure the Ubuntu system is updated.
    $ sudo apt update
    [sudo] password for jerry: 
    Get:1 focal-security InRelease [114 kB]
    Hit:2 focal InRelease
    Get:3 focal-updates InRelease [114 kB]
    Get:4 focal-backports InRelease [108 kB]
    Get:5 focal-updates/main i386 Packages [581 kB]
    Get:6 focal-updates/main amd64 Packages [1,445 kB]
    Get:7 focal-updates/universe amd64 Packages [892 kB]                                                                               
    Get:8 focal-updates/universe i386 Packages [662 kB]                                                                                
    Fetched 3,915 kB in 19s (205 kB/s)                                                                                                                                     
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    191 packages can be upgraded. Run 'apt list --upgradable' to see them.
  2. Run the command sudo apt install build-essential to install GCC. The build-essential package is the meta-package, it contains a set of tools that includes GNU debugger, g++/GNU compiler.
    $ sudo apt install build-essential
    Reading package lists... Done
    Building dependency tree 
    Processing triggers for man-db (2.9.1-1) ...
    Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
  3. Run the command gcc –version again to verify the GCC has been installed successfully.
    $ gcc --version
    gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
    Copyright (C) 2019 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
  4. Get where the GCC is installed with the below command.
    $ whereis gcc make
    gcc: /usr/bin/gcc /usr/lib/gcc /usr/share/gcc /usr/share/man/man1/gcc.1.gz
    make: /usr/bin/make /usr/share/man/man1/make.1.gz
  5. Run the command make -v to get the make version.
    $ make -v
    GNU Make 4.2.1
    Built for x86_64-pc-linux-gnu
    Copyright (C) 1988-2016 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.

4 thoughts on “How To Install The Latest GCC On Ubuntu”

  1. The title of this article is misleading. It only explains how to install the *default* GCC version for your system, not the *latest* GCC version as the title implies.

    1. Yes, I also was looking for the latest (experimental) version, because I need to test features not supported in the current stable release.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.