On any given Ubuntu release, build-essential provides the most commonly needed tools for building packages for that release, by declaring dependencies on various other packages.

Two of the packages build-essential always depends on are gcc and g++. On each release, those packages provide (parts of) the GNU Compiler Collection at the default version for that release, which is the version that is typically used to compile programs for that release. In particular, it is the version that is used to build all the binary packages provided in Ubuntu's official repositories. Another way to say this is that it's the version that is used to build that release of Ubuntu.

Others have pointed out why Ubuntu releases deliberately often do not provide the very latest versions of software. Although the StableReleaseUpdates policy does apply to packages that provide development tools, that nonetheless doesn't really answer why build-essential doesn't always depend on the latest tools, because build-essential often doesn't even depend on the latest tools that are officially packaged for the release.

For example, as I write this, the latest stable version of Ubuntu is 19.04. (It's not an LTS release, but it's a stable release.) The gcc and g++ packages, which build-essential depends on, provide GCC 8.3 on Ubuntu 19.04. However, GCC 9.1 is packaged in the official repositories for Ubuntu 19.04; it is provided by packages whose names end in -9. In particular, for GCC 9.1 instead of GCC 8.3, you would install the gcc-9 package instead of the gcc package and the g++-9 package instead of the g++ package. (You don't really have to install one version instead of the other; gcc and gcc-9, as well as g++ and g++-9, can be installed at the same time with no conflicts.)

It's true that the stable release updates policy is the reason Ubuntu 18.04 LTS does not happen to have GCC 9. But that's not the reason the build-essential, gcc, and g++ packages give you the older version of GCC--the version that was used to build the binary packages available for the system. (In 18.04 LTS, that version happens to be GCC 7.2.) The point of build-essential is to give you the tools that are recommended, and officially used, for building packages for your release, and the purpose of the gcc and g++ packages is to provide the components of GCC, including the gcc and g++ commands, that are used for that purpose.

So even when an Ubuntu release officially provides later versions of GCC than the version that is used to build the system, those packages provide the earlier version.

Answer from Eliah Kagan on askubuntu.com
🌐
Linuxize
linuxize.com › home › gcc › how to install gcc (build-essential) on ubuntu 20.04
How to Install GCC (build-essential) on Ubuntu 20.04 | Linuxize
June 4, 2020 - This article explains how to install GCC on Ubuntu 20.04. The default Ubuntu repositories contain a meta-package named build-essential that includes the GNU compiler collection and other development …
Top answer
1 of 1
1

On any given Ubuntu release, build-essential provides the most commonly needed tools for building packages for that release, by declaring dependencies on various other packages.

Two of the packages build-essential always depends on are gcc and g++. On each release, those packages provide (parts of) the GNU Compiler Collection at the default version for that release, which is the version that is typically used to compile programs for that release. In particular, it is the version that is used to build all the binary packages provided in Ubuntu's official repositories. Another way to say this is that it's the version that is used to build that release of Ubuntu.

Others have pointed out why Ubuntu releases deliberately often do not provide the very latest versions of software. Although the StableReleaseUpdates policy does apply to packages that provide development tools, that nonetheless doesn't really answer why build-essential doesn't always depend on the latest tools, because build-essential often doesn't even depend on the latest tools that are officially packaged for the release.

For example, as I write this, the latest stable version of Ubuntu is 19.04. (It's not an LTS release, but it's a stable release.) The gcc and g++ packages, which build-essential depends on, provide GCC 8.3 on Ubuntu 19.04. However, GCC 9.1 is packaged in the official repositories for Ubuntu 19.04; it is provided by packages whose names end in -9. In particular, for GCC 9.1 instead of GCC 8.3, you would install the gcc-9 package instead of the gcc package and the g++-9 package instead of the g++ package. (You don't really have to install one version instead of the other; gcc and gcc-9, as well as g++ and g++-9, can be installed at the same time with no conflicts.)

It's true that the stable release updates policy is the reason Ubuntu 18.04 LTS does not happen to have GCC 9. But that's not the reason the build-essential, gcc, and g++ packages give you the older version of GCC--the version that was used to build the binary packages available for the system. (In 18.04 LTS, that version happens to be GCC 7.2.) The point of build-essential is to give you the tools that are recommended, and officially used, for building packages for your release, and the purpose of the gcc and g++ packages is to provide the components of GCC, including the gcc and g++ commands, that are used for that purpose.

So even when an Ubuntu release officially provides later versions of GCC than the version that is used to build the system, those packages provide the earlier version.

People also ask

Does GCC come pre-installed on Ubuntu?
No. Ubuntu desktop and server images do not include GCC by default. You need to install the build-essential package, which provides GCC, G++, make, and essential development headers.
🌐
linuxcapable.com
linuxcapable.com › home › ubuntu › how to install gcc on ubuntu (26.04, 24.04, 22.04)
How to Install GCC on Ubuntu (26.04, 24.04, 22.04) - LinuxCapable
How do I fix "gcc: command not found" on Ubuntu?
Ubuntu does not include GCC by default. Install it with sudo apt install build-essential, which provides gcc, g++, and make. If you installed a specific version like gcc-14, either use the versioned binary (gcc-14) directly or register it with update-alternatives to create the unversioned gcc symlink.
🌐
linuxcapable.com
linuxcapable.com › home › ubuntu › how to install gcc on ubuntu (26.04, 24.04, 22.04)
How to Install GCC on Ubuntu (26.04, 24.04, 22.04) - LinuxCapable
What is the default GCC version on each Ubuntu LTS release?
Ubuntu 26.04 LTS defaults to GCC 15 with versions 11 through 16 available, Ubuntu 24.04 LTS defaults to GCC 13 with versions 9 through 14 available, and Ubuntu 22.04 LTS defaults to GCC 11 with versions 9 through 12 available. Install the build-essential package to get the default compiler for your release.
🌐
linuxcapable.com
linuxcapable.com › home › ubuntu › how to install gcc on ubuntu (26.04, 24.04, 22.04)
How to Install GCC on Ubuntu (26.04, 24.04, 22.04) - LinuxCapable
🌐
PhoenixNAP
phoenixnap.com › home › kb › sysadmin › how to install gcc compiler on ubuntu
How to Install GCC Compiler on Ubuntu {3 Simple Methods}
February 20, 2025 - To install the GCC compiler from Ubuntu repositories: ... The build-essential package includes the GCC compiler and other utilities required for building software.
🌐
Medium
maneeshkush.medium.com › how-to-install-gcc-build-essential-on-ubuntu-20-04-af220d8986e5
How to Install GCC (build-essential) on Ubuntu 20.04 | by Maneesh kushwaha | Medium
June 6, 2020 - This text explains the right way to set up GCC on Ubuntu 20.04. The default Ubuntu repositories include a meta-package named “build-essential” that features the GNU compiler assortment, GNU debugger, and different growth libraries and instruments required for compiling software program. To put in the Growth Instruments packages, run the next command as root or user with sudo privileges: ... The command installs plenty of packages, together with gcc, g++ and make.
🌐
AllThings
allthings.how › how-to-install-gcc-build-essential-on-ubuntu-20-04
How to Install GCC (build-essential) on Ubuntu 20.04
June 19, 2020 - It includes several other essential tools and libraries such as g++, make, dpkg-dev required for compiling software on Ubuntu. To install the build-essential package, open the terminal using Ctrl+Alt+T keys and run the following commands:
Top answer
1 of 2
2
  1. Check your /etc/apt/sources.list, maybe you have multiple distributions?
  2. It says, gcc (at least from version 4.4.3) is not installable, why? You can test this easily by trying to install this with a command apt-get install gcc.
  3. Check if your system has only clean packages with the dpkg -C command. If there are damaged or unconfigured packages, fix them with dpkg --configure -a or by removing/reinstalling them.

Often happens, that you have some packages in multipe versions in your remote repositories. For example, you have a build-essential from testing and stable, but the corresponding gcc is only reachable from stable. The consequence:

  • Trying to install the build-essential, the package manager tries to get your latest package version,
  • but this package version required a newer gcc version as you have in your stable repository.

Similar problems you can easily check with a simple apt-cache show build-essential. If you get multiple packages (with differing versions) you can consider to get a try to an earlier. apt-get install packagename=1.2.3 will install you the package with version 1.2.3 .

I suggest to extend your question with the output of your commands.

2 of 2
1

Found a solution. After more experimenting I found that it was not possible to install other packages using apt as well. Then I noticed that there were hash sum mismatch errors when running apot-get update. In the end I found running the following commands fixed my issue:

apt-get clean
rm -rf /var/lib/apt/lists/*
apt-get clean
apt-get update
apt-get upgrade

After running this I am now able to install build-essential package.

Find elsewhere
🌐
Linux Hint
linuxhint.com › install-build-essential-ubuntu
What is build-essential Ubuntu, how to install and use it? – Linux Hint
Now, you need to update the packages repository before installing the build-essential tools. Type the following command to update the apt repository index: ... Once the installation is finished, verify the installation of these packages by checking the GCC version on your system with the following command: ... The installed version of GCC to be displayed on the terminal, which is also shown in the following screenshot: Now, all GCC compiler libraries and tools have been installed on Ubuntu 20.04 system.
🌐
Ubuntu Shell
ubuntushell.com › install-gcc-on-ubuntu
How to Install GCC on Ubuntu 25.04: A Step-By-Step Guide
November 13, 2025 - $ sudo apt update $ sudo apt install build-essential ... Once the installation is complete, check the GCC version to verify its installation. ... To write and compile a C/C++ program using GCC on Ubuntu 25.04, follow the steps below sequentially.
🌐
LinuxCapable
linuxcapable.com › home › ubuntu › how to install gcc on ubuntu (26.04, 24.04, 22.04)
How to Install GCC on Ubuntu (26.04, 24.04, 22.04) - LinuxCapable
December 6, 2023 - Ubuntu does not include GCC by default. Install it with sudo apt install build-essential, which provides gcc, g++, and make.
🌐
Ubuntu
help.ubuntu.com › community › InstallingCompilers
InstallingCompilers - Community Help Wiki
$ sudo apt-get update $ sudo apt-get upgrade $ sudo apt-get install build-essential $ gcc -v $ make -v
🌐
Tech Edu Byte
techedubyte.com › home › install gcc and build-essential tools on ubuntu 20.04 easily
Install GCC and Build-Essential Tools on Ubuntu 20.04 Easily - Tech Edu Byte
3 weeks ago - This article explains how to install GCC on Ubuntu 20.04. The default Ubuntu repositories contain a meta-package named build-essential that includes the GN
🌐
Cherry Servers
cherryservers.com › home › blog › linux › how to install gcc on ubuntu 22.04 [and compile a c program]
How to Install GCC on Ubuntu 22.04 [and Compile a C Program] | Cherry Servers
November 7, 2025 - To install build-essentials, use the following command: ... gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 Copyright (C) 2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions.
🌐
Medium
medium.com › @adwalkz › demystifying-development-a-guide-to-build-essential-in-ubuntu-for-seamless-software-compilation-b590b5a298bb
Demystifying Development: A Guide to ‘build-essential’ in Ubuntu for Seamless Software Compilation | by Aditya Jain | Medium
January 12, 2024 - You can install build-essential on Ubuntu using the following command: sudo apt-get update sudo apt-get install build-essential · When you run sudo apt install gcc, you are installing the GNU Compiler Collection (GCC) specifically.
🌐
DedicatedCore
dedicatedcore.com › home › how to install gcc compiler on ubuntu 22.04
How to Install GCC Compiler on Ubuntu 22.04 - DedicatedCore Blog
January 24, 2025 - GCC compiler installation through Ubuntu repository: Use the command below to update the Ubuntu package repository: ... The GCC compiler, along with other tools needed for software development, is included in the build-essential package.
🌐
Reddit
reddit.com › r/linux4noobs › what is build-essential and why i need it to program in c++?
r/linux4noobs on Reddit: What is build-essential and why I need it to program in C++?
November 5, 2023 -

I am a new user on Debian and I want to learn how to program in C++. I have seen that to program in C++, I need a compiler called g++. Many websites suggest that I should install the build-essential package to program in C++, but my question is whether I can't just download g++ alone. Also, I would like to know what I would be missing if I only install g++ and not build-essential. Thank you, and I apologize for my ignorance.

Top answer
1 of 8
18
build-essential is what we call on the lingo a "meta-package" (a package of packages). Each distro and package manager may call them differently, but in essence they are packages that are almost empty so they barely install anything by themselves. Instead they are ways of installing whole suites of software as they have all the required programs listed as dependencies, so by installing the meta-package you install tons of useful programs at once. build-essential is a meta-package that lists programs that will be needed if you want to develop debian packages. It is often recommended as it comes with both gcc and g++, but also some useful utilities like the make program (allows you to make scripts for automated compilation) and other stuff. You can get g++ for separate, but the other tools that build-essential may come in hand later. I mean, they take barely some megabytes, so there is not that much cost of having them.
2 of 8
8
Understanding this involves a little side trip down package management lane. Disclaimer: This is slightly simplified to make it easier to understand. You're likely familiar with Windows-land, where you download an installer, it installs stuff on your system, end of story. Everything the program needs to run is packaged along with that installer. In Linux most distros rely on package managers, which contain a list of all the different dependencies a certain package may have. So for example a little program like KCalk requires something in order to handle the graphical user interface, in this case it would use the Qt library . So when you install KCalk, the package manager checks whether Qt is installed, and if it's not it installs it as well. Having this system in place allows for something called "meta packages". Basically a package that in itself contains nothing, but is only designed so that you can install all its dependencies in one go. Think of it like telling your buddy "Buy all the things required for superbowl night" rather than listing the items. In the case of Debian's Build Essential package the dependencies are: dpkg-dev: The development headers for the Debian package manager. Probably not useful for your needs. g++: The GNU C++ compiler. gcc: The GNU Compiler Collection, in case you need to compile C. libc6-dev: The libc standard library. libc6.1-dev: Same as the above, different version. make: GNU Make , this is used to build larger packages of software i.e. if your program is 50 files, Make knows how to compile them and link them together, instead you manually calling g++ 50 times. You could in theory just install these packages manually, but trust me, learning C++ is one hell of a rabbit hole to jump into. Just take the build-essential package and move forward. Trying to fiddle with these things comes a long long time after the "starting C++" point of your journey. Another piece of advice regarding C++: The language was first standardized in 1998, and it existed in various non-standard forms before that. This means the language is more than 25 years old at this point, and it was based on C which was standardized in 1978. There is a lot of old stuff in the language. When you find something weird in the language and ask yourself "why is this so fucked?" the answer is usually because of "historical baggage and backwards compatibility." Try to learn "modern C++" i.e. at the very least the 2011 version known as C++11 as there were huge changes to the language in that version. C++17 and C++23 are also available, and while the changes are amazing, they are a smaller jump than C++11 was.
🌐
It's FOSS
itsfoss.com › build-essential-ubuntu
What is Build Essential Package in Ubuntu? How to Install it?
September 4, 2023 - The apt update command refreshes the local package cache. This is essential for a fresh Ubuntu install. After that, run the following command to install build-essential tool:
🌐
LinuxVox
linuxvox.com › blog › how-to-install-gcc-build-essential-on-ubuntu-20-04
How to Install GCC (build-essential) on Ubuntu 20.04 — linuxvox.com
While GCC itself is powerful, Ubuntu simplifies installation by bundling GCC with essential build tools (like `make`, `libc6-dev`, and `dpkg-dev`) into a meta-package called `build-essential`. In this guide, we’ll walk through installing ...
🌐
Tech Edu Byte
techedubyte.com › home › install gcc and build tools on ubuntu 20.04 with build-essential
Install GCC and Build Tools on Ubuntu 20.04 with build-essential - Tech Edu Byte
3 weeks ago - This article explains how to install GCC on Ubuntu 20.04. The default Ubuntu repositories contain a meta-package named build-essential that includes the GN