How To Install GCC Compiler On Ubuntu (3 Simple Methods)
How To Install GCC Compiler On Ubuntu (3 Simple Methods)
com/kb/install-gcc-ubuntu
August 2, 2023
UBUNTU
Introduction
The GCC (GNU Compiler Collection) is a free software compiler system capable of compiling several programming
languages, including C, C++, Objective-C, and Fortran.
Developers who want to build C or C++ software on a Linux-based system need a reliable compiler like GCC.
Find out how to install GCC on Ubuntu and start compiling code on your system in no time.
Prerequisites
• Ubuntu 20.04 or Ubuntu 22.04 installed.
• Access to a terminal window/command line.
• A user account with root or sudo privileges.
1 of 9 1/17/25, 1�08 AM
How to Install GCC Compiler on Ubuntu {3 Simple Methods} https://phoenixnap.com/kb/install-gcc-ubuntu
The build-essential package includes the GCC compiler and other utilities required for building software.
gcc --version
To do so:
2 of 9 1/17/25, 1�08 AM
How to Install GCC Compiler on Ubuntu {3 Simple Methods} https://phoenixnap.com/kb/install-gcc-ubuntu
3. Add the GCC PPA that contains all the versions of the GCC compiler:
5. Use the command below to install a speci�c version or multiple versions of GCC. For example, to install GCC 12 and
GCC 13, enter:
Note: There are no restrictions to the number of GCC versions you can install using this installation
method.
3 of 9 1/17/25, 1�08 AM
How to Install GCC Compiler on Ubuntu {3 Simple Methods} https://phoenixnap.com/kb/install-gcc-ubuntu
Note: Replace the GCC version in the example commands (GCC 12 and 13) with the GCC versions
installed on your system.
The system displays a list of the installed GCC versions and asks to select the default version. Enter the selection number
for the version you want to use.
gcc --version
To retrieve the GCC source code from o�cial repositories and install the GCC compiler:
4 of 9 1/17/25, 1�08 AM
How to Install GCC Compiler on Ubuntu {3 Simple Methods} https://phoenixnap.com/kb/install-gcc-ubuntu
2. Install the libgmp3-dev, libmpfr-dev, and libmpc-dev packages to facilitate compiling GCC from source:
3. Use the wget command to download the GCC source code from the GCC website. In this example, the �le
gcc-13.2.0.tar.gz contains the source code for GCC version 13.2.0:
wget http://ftp.gnu.org/gnu/gcc/gcc-13.2.0/gcc-13.2.0.tar.gz
Adjust the URL in the command to re�ect the GCC version you want to install.
cd gcc-13.2.0
5 of 9 1/17/25, 1�08 AM
How to Install GCC Compiler on Ubuntu {3 Simple Methods} https://phoenixnap.com/kb/install-gcc-ubuntu
Visit the o�cial GNU GCC con�guration page to review available options and recommended con�guration procedures.
make -j3
The build process can consume a lot of resources and take a while to complete. The j3 command tells the system to use
three cores for the operation. Change the number of cores to re�ect your system's capabilities and setup.
8. After the build process is complete, install GCC using the following command:
/usr/local/gcc-13.2.0/bin/gcc-13.2.0 --version
Conclusion
You now know how to install the GCC compiler on Ubuntu using three different methods. Regardless of the method,
installing GCC on an Ubuntu machine allows you to compile and run C and C++ code and complete many programming,
debugging, and system administration tasks.
Check out these �ve different test automation frameworks that make automated testing faster and more reliable.
6 of 9 1/17/25, 1�08 AM
How to Install GCC Compiler on Ubuntu {3 Simple Methods} https://phoenixnap.com/kb/install-gcc-ubuntu
Vladimir Kaplarevic
Vladimir is a resident Tech Writer at phoenixNAP. He has more than 7 years of experience in implementing e-commerce
and online payment solutions with various global IT services providers. His articles aim to instill a passion for innovative
technologies in others by providing practical advice and using an engaging writing style.
DevOps and
Development,
SysAdmin
22 Best Linux Text
Editors for
Programming &
Coding
August 8, 2024
A text editor is an
application that lets
you type text. All Linux
distributions come
with built-in editors, but
there are also other
options. In this article,
we review the 22 best
text editors.
READ MORE
Security, SysAdmin
How to Build
Linux Kernel From
Scratch
November 12, 2020
7 of 9 1/17/25, 1�08 AM
How to Install GCC Compiler on Ubuntu {3 Simple Methods} https://phoenixnap.com/kb/install-gcc-ubuntu
RE
RE
SysAdmin
How To Install and
Use Linux Screen
April 7, 2022
Screen is a powerful
tool for working in the
command line. It lets
you create, monitor,
and switch between
several different
windows.
READ MORE
DevOps and
Development,
SysAdmin
15 Best DevOps
Tools IT Experts
Use
August 2, 2023
8 of 9 1/17/25, 1�08 AM
How to Install GCC Compiler on Ubuntu {3 Simple Methods} https://phoenixnap.com/kb/install-gcc-ubuntu
9 of 9 1/17/25, 1�08 AM