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 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
    Hit:2 http://cn.archive.ubuntu.com/ubuntu focal InRelease
    Get:3 http://cn.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
    Get:4 http://cn.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
    Get:5 http://cn.archive.ubuntu.com/ubuntu focal-updates/main i386 Packages [581 kB]
    Get:6 http://cn.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [1,445 kB]
    Get:7 http://cn.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [892 kB]                                                                               
    Get:8 http://cn.archive.ubuntu.com/ubuntu 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
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  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 <http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.
    
0 0 votes
Article Rating
Subscribe
Notify of
guest

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

0 Comments
Inline Feedbacks
View all comments
Clicky
0
Would love your thoughts, please comment.x
()
x