To update GCC on your system, the method depends on your operating system and desired version:

Ubuntu/Debian

  • Use APT (Recommended for most users):
    Ubuntu 24.04 and later include GCC 14 in the Universe repository. Enable it and install:

    sudo add-apt-repository universe
    sudo apt update
    sudo apt install gcc-14 g++-14

    Verify with gcc-14 --version.

  • Use PPA for newer versions (e.g., GCC 15+):
    The ppa:ubuntu-toolchain-r/test PPA provides updated builds. Add it and install:

    sudo add-apt-repository ppa:ubuntu-toolchain-r/test
    sudo apt update
    sudo apt install gcc-15 g++-15
  • Compile from source (for bleeding-edge versions like GCC 16):
    Follow the guide from Medium to build GCC 15.1 or later from source using git, configure, and make. After building, register the new compiler with update-alternatives:

    sudo update-alternatives --install /usr/bin/gcc gcc /opt/gcc-15/bin/gcc 100
    sudo update-alternatives --install /usr/bin/g++ g++ /opt/gcc-15/bin/g++ 100

Windows

  • Use GCC-win64 (e.g., GCC 14):
    Install via Geeky Script's guide using MinGW-w64 with GCC 14. Download the latest release from mingw-w64 or use tools like MSYS2.

Latest GCC Version

  • The latest stable release is GCC 15.2, released on August 8, 2025.

  • Development for GCC 16.0 is ongoing, with regression fixes and documentation updates as of January 2026.

Note: Always back up your environment before switching default compilers. Use update-alternatives to manage multiple versions safely.

This is a common pattern in linux. When there are multiple versions of the same program installed, though the executables are all present in the /usr/bin/ directory, only one of them is "visible" as that program. For example, if you install gcc-9 and gcc-10, both executables are present as /usr/bin/gcc-9 and /usr/bin/gcc-10 but only one of them is visible as gcc. This happens by symlinking a preferred version to the same directory as /usr/bin/gcc. In ubuntu 20.04, the preferred version is gcc-9 and so, gcc-9 is symlinked as gcc.

You can check this by running the following command.

$ which gcc | xargs file

The output will be

/usr/bin/gcc: symbolic link to gcc-9

There are a few things you can do to use gcc-10 as your c compiler.

  1. Directly call the gcc-10 executable. Instead of using gcc <code.c>, call gcc-10 <code.c>.
  2. You can manually symlink gcc-10 as the preferred gcc. Assuming you did not modify the system paths, the following command can be used.
# ln -s /usr/bin/gcc-10 /usr/local/bin/gcc

This works because, by default, the executables in /usr/local/bin/ take precedence over /usr/bin/.

  1. If you are using bash, you can create an alias for gcc as gcc-10. Add the following line to your .bashrc.
alias gcc="gcc-10"

Remember to relaunch bash or source ~/.bashrc.

  1. Using update-alternatives (Thanks to @ted-lyngmo for pointing it out). Debian based distributions supply a separate program, that can make symlinking easier / more functional. Read more using man update-alternatives. To use gcc-10 as the preferred gcc, use the following command.
# update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 60

The above command says, /usr/bin/gcc is the link needed and the name is gcc, the target executable is /usr/bin/gcc-10 and it has a priority of 60.

This links gcc to /etc/alternatives/gcc, which itself is a symlink to /usr/bin/gcc-10. If a higher priority program is added to update-alternatives, /etc/alternatives/gcc points to the higher priority program.

If you don't have any specific reason, I would also recommend to upgrade to a newer ubuntu version, so that the default gcc is a newer one.

I read on the gcc website that version 9.4 is more up-to-date than some 10.x versions.

With newer gcc versions, new features are added. Support for newer c/c++ standards are also added. Eg. You can read the changes for gcc-10 here. But people still need gcc-9 because some programs only build with gcc-9. So, GNU maintains gcc-9 (and much older versions) for a long time. Bugs are fixed, and newer releases are made. This can happen after the release of a newer gcc version. So, it is very much possible that a version of gcc-9 is newer than a version of gcc-10.

Answer from berinaniesh on Stack Overflow
Top answer
1 of 1
18

This is a common pattern in linux. When there are multiple versions of the same program installed, though the executables are all present in the /usr/bin/ directory, only one of them is "visible" as that program. For example, if you install gcc-9 and gcc-10, both executables are present as /usr/bin/gcc-9 and /usr/bin/gcc-10 but only one of them is visible as gcc. This happens by symlinking a preferred version to the same directory as /usr/bin/gcc. In ubuntu 20.04, the preferred version is gcc-9 and so, gcc-9 is symlinked as gcc.

You can check this by running the following command.

$ which gcc | xargs file

The output will be

/usr/bin/gcc: symbolic link to gcc-9

There are a few things you can do to use gcc-10 as your c compiler.

  1. Directly call the gcc-10 executable. Instead of using gcc <code.c>, call gcc-10 <code.c>.
  2. You can manually symlink gcc-10 as the preferred gcc. Assuming you did not modify the system paths, the following command can be used.
# ln -s /usr/bin/gcc-10 /usr/local/bin/gcc

This works because, by default, the executables in /usr/local/bin/ take precedence over /usr/bin/.

  1. If you are using bash, you can create an alias for gcc as gcc-10. Add the following line to your .bashrc.
alias gcc="gcc-10"

Remember to relaunch bash or source ~/.bashrc.

  1. Using update-alternatives (Thanks to @ted-lyngmo for pointing it out). Debian based distributions supply a separate program, that can make symlinking easier / more functional. Read more using man update-alternatives. To use gcc-10 as the preferred gcc, use the following command.
# update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 60

The above command says, /usr/bin/gcc is the link needed and the name is gcc, the target executable is /usr/bin/gcc-10 and it has a priority of 60.

This links gcc to /etc/alternatives/gcc, which itself is a symlink to /usr/bin/gcc-10. If a higher priority program is added to update-alternatives, /etc/alternatives/gcc points to the higher priority program.

If you don't have any specific reason, I would also recommend to upgrade to a newer ubuntu version, so that the default gcc is a newer one.

I read on the gcc website that version 9.4 is more up-to-date than some 10.x versions.

With newer gcc versions, new features are added. Support for newer c/c++ standards are also added. Eg. You can read the changes for gcc-10 here. But people still need gcc-9 because some programs only build with gcc-9. So, GNU maintains gcc-9 (and much older versions) for a long time. Bugs are fixed, and newer releases are made. This can happen after the release of a newer gcc version. So, it is very much possible that a version of gcc-9 is newer than a version of gcc-10.

🌐
GIGABYTE
gigabyte.com › consumer › software › gigabyte-control-center
GIGABYTE CONTROL CENTER - GIGABYTE Global
GIGABYTE Control Center (GCC) is a unified software platform across a variety of GIGABYTE products. Every available utility preferred is optimized and integrated with intuition ...
Discussions

Should I update all the things GCC says?
Only do the updates that have the name "driver" in them. Then uninstall Norton and uninstall GCC. Moving forward check the support page of your motherboard and periodically download the driver updates and apply those. More on reddit.com
🌐 r/gigabyte
23
7
September 16, 2023
yum - How to update the version of gcc-c++ on Fedora? - Unix & Linux Stack Exchange
I have version 4.4.4 of gcc installed and would like to update to either a specific version or to the latest version. Here is what I have tried: sudo yum install gcc-c++ this tells me that Package... More on unix.stackexchange.com
🌐 unix.stackexchange.com
April 10, 2013
Need help updating GCC/G++ from MinGW
https://winlibs.com/ you probably want GCC 13.2.0 (with POSIX threads) + LLVM/Clang/LLD/LLDB 16.0.6 + MinGW-w64 11.0.0 (UCRT) - release 1 (LATEST) Win64: 7-Zip archive* | Zip archive - without LLVM/Clang/LLD/LLDB: 7-Zip archive* | Zip archive and choose the Win64 Zip archive (the first Zip archive in that link) version_info.txt says winlibs personal build version gcc-13.2.0-llvm-16.0.6-mingw-w64ucrt-11.0.0-r1 This is the winlibs Intel/AMD 64-bit standalone build of: GCC 13.2.0 GDB 13.2 LLVM/Clang/LLD/LLDB 16.0.6 MinGW-w64 11.0.0 (linked with ucrt) GNU Binutils 2.40 GNU Make 4.4.1 PExports 0.47 dos2unix 7.5.0 Yasm 1.3.0 NASM 2.16.01 JWasm 2.12pre ccache version 4.8.2 CMake 3.27.1 ninja 1.11.1 doxygen 1.9.7 Thread model: posix Runtime library: UCRT (Windows 10 or higher, or when Update for Universal C Runtime is installed on older Windows versions, not supported on systems older than Windows 7 SP1 and Windows Server 2008 R2 SP1) This build was compiled with GCC 13.2.0 and packaged on 2023-07-28. More on reddit.com
🌐 r/cpp_questions
13
3
October 17, 2023
GCC update completely killed RAM RGB control
Double check to see if Windows isn't getting in the way. It has an RGB controller of its own. More on reddit.com
🌐 r/gigabyte
23
4
January 8, 2026
People also ask

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
Can I have multiple GCC versions installed at the same time?
Yes. Install each version separately and use the update-alternatives system to register and switch between them. This lets you set a system-wide default while switching to a specific version for individual projects.
🌐
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
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
🌐
openSUSE Forums
forums.opensuse.org › english › applications
Upgrade gcc c++ compiler - Applications - openSUSE Forums
December 24, 2020 - In order to compile a software package from a compilation failure, I am told to upgrade the gcc-c++ compiler from default version 7 to version 10 as there are needed updated compiler modules. I have installed version gc…
🌐
Medium
medium.com › @xersendo › moving-to-c-26-how-to-build-and-set-up-gcc-15-1-on-ubuntu-f52cc9173fa0
Moving to C++26: How to Build and Set Up GCC 15.1 on Ubuntu
May 3, 2025 - That’s because we still need to tell the system to use our shiny new GCC by default. sudo update-alternatives --install /usr/bin/gcc gcc /opt/gcc-15/bin/gcc 100 sudo update-alternatives --install /usr/bin/g++ g++ /opt/gcc-15/bin/g++ 100
🌐
Reddit
reddit.com › r/gigabyte › should i update all the things gcc says?
r/gigabyte on Reddit: Should I update all the things GCC says?
September 16, 2023 -

Hey guys,

I've read everywhere that GCC is dog water, but wanted to double check if I should or shouldn't update all the things it is telling me, for example:

I just built this PC and everything is working fine, so am a bit cautious of this. Also, for some reason on my gb 4070 aorus master, my gpu is not even being detected in rgb fusion 2.0.

Any ideas?

Find elsewhere
🌐
Al Jazeera
aljazeera.com › gcc
GCC | Today's latest from Al Jazeera
3 days ago - Visit comes as Asaad Hassan al-Shaibani, Syria’s newly appointed foreign minister, meets GCC officials in Damascus.
🌐
SourceForge
sourceforge.net › projects › gcc-win64
gcc-win64 download | SourceForge.net
Download gcc-win64 for free. x64 build of GCC for Windows. x64 C/C++ compiler for Windows using (unofficial build): - gmp - mpfr - mpc - isl - cloog - mingw-w64 - gcc - seh You need at least core2 command set support to run this application. Note that every version with bundled gdb needs at ...
Top answer
1 of 5
240

The best way to correctly install gcc-4.9 and set it as your default gcc version use:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.9 g++-4.9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9

The --slave, with g++, will cause g++ to be switched along with gcc, to the same version. But, at this point gcc-4.9 will be your only version configured in update-alternatives, so add 4.8 to update-alternatives, so there actually is an alternative, by using:

sudo apt-get install gcc-4.8 g++-4.8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8

Then you can check which one that is set, and change back and forth using:

sudo update-alternatives --config gcc

If you have an issue with update-alternatives gcc priority 60 not being higher than previous versions installed you can use the previous update-alternatives --config gcc command to check installed versions and use:

sudo update-alternatives --remove gcc

Or:

sudo update-alternatives --remove-all gcc

NOTE: You could skip installing the PPA Repository and just use /usr/bin/gcc-4.9-base but I prefer using the fresh updated toolchains.


For GCC 5.X or 6, the packages (and correspondingly, the commands) are just called gcc-5, gcc-6, etc. This is due to the change in GCC's version scheme, where 5.1 is the first GCC 5 release, and future 5.X releases are for bug fixes.

2 of 5
63

Ultimate mega master compatibility table

OK let's do this:

                  GCC                              clang
        +-------------------------------------+-------------------------------------------------+
        | 15 14 13 12 11 10  9  8  7  6  5  4 | 20 19 18 17 16 15 14 13 12 11 10  9  8  7  6  5 |
+-------+-------------------------------------+-------------------------------------------------+
| 25.10 |  D  M  M  M  M                      |  D  M  M  M                                     |
| 25.04 |     D  M  M  M                      |  D  M  M  M                                     |
| 24.10 |     D  M  M  M                      |     D  M  M  M  M  M                            |
| 24.04 |     M  D  M  M  M  M                |        D  M  M  M  M                            |
| 23.10 |        D  M  M  M  M                |           M  D  M  M  M                         |
| 23.10 |        D  M  M  M  M                |              D  M  M  M                         |
| 23.04 |        M  D  M  M  M                |              M  D  M  M                         |
| 22.10 |           D  M  M  M                |                 D  M  M                         |
| 22.04 |        P  M  D  M  M                |                    D  M  M  M                   |
| 21.10 |              D  M  M  M             |                       D  M  M  M  M             |
| 21.04 |              M  D  M  M  M          |                          D  M  M  M             |
| 20.10 |                 D  M  M  M          |                             D  M  M  M  M  M    |
| 20.04 |                 P  D  M  M          |                                D  M  M  M  M    |
| 19.10 |                    D  M  M          |                                                 |
| 19.04 |                    M  D  M  M       |                                                 |
| 18.10 |                       D  M  M  M    |                                                 |
| 18.04 |                 P  P  M  D  M  M    |                                   M  M  M  D  M |
| 16.04 |                    P  P  P  P  D  M |                                                 |
+-------+-------------------------------------+-------------------------------------------------+
  • D: Default GCC

    sudo apt-get update
    sudo apt-get install gcc g++
    gcc --version
    

    Whatever the gcc package aliases to: https://packages.ubuntu.com/search?keywords=gcc and also present in manifests: How do I list the default installed packages?

  • M: Present in Main repo

    sudo apt-get update
    sudo apt-get install gcc-X g++-X
    gcc-X --version
    

    All Ubuntu versions that have a hit for a given GCC version, e.g. for GCC 7: https://packages.ubuntu.com/search?keywords=gcc-7 or clang 7 https://packages.ubuntu.com/search?keywords=clang-7

    The minor versions of these packages can get updated from time to time within a single Ubuntu version (on the . revisions?), e.g. 8.3.0 to 8.4.0 so we are not keeping track of that.

  • P: ppa:ubuntu-toolchain-r/test, which is owned by Ubuntu people and therefore can be trusted to not be a virus, although it is possibly unstable:

    sudo add-apt-repository ppa:ubuntu-toolchain-r/test
    sudo apt-get update
    sudo apt-get install gcc-X g++-X
    gcc-X --version
    

    Full list: https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test

    The minor versions of these packages can get updated from time to time, e.g. 8.3.0 to 8.4.0.

Blank spaces on the table mean either "no package available" or "I didn't bother to check". Notably I've not been looking into PPA packages too thoroughly. Edits accepted.

All the questions:

  • install gcc-9 on Ubuntu 18.04?
  • How to install gcc-7 or clang 4.0?
  • install gcc-9 on Ubuntu 18.04?
  • What are the GCC and clang versions available in Ubuntu 18.04?

How to set a non-default GCC as the default?

E.g., you installed /usr/bin/gcc-7 but you want to use that instead of /usr/bin/gcc when you run gcc main.c.

Use sudo update-alternatives as mentioned in other answers: https://askubuntu.com/a/581497/52975 It creates the required symlinks for you.

See also: What exactly does `update-alternatives` do?

How to build your own toolchain from source

If even the PPA is not old/new enough for you, see this:

  • https://stackoverflow.com/questions/847179/multiple-glibc-libraries-on-a-single-host/52454603#52454603
  • https://stackoverflow.com/questions/26305738/can-i-build-gcc-for-arm-with-an-x64-one/26306591#26306591

Older GCC version questions

  • Ubuntu 20.04 - gcc version lower than gcc-7
  • How to use an older version of GCC
🌐
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
1 week ago - Install GCC on Ubuntu 26.04, 24.04 and 22.04 via APT or the Toolchain PPA. Configure multiple versions with update-alternatives.
🌐
GitHub
gist.github.com › cobaohieu › ded429cb892b46ae9bfd9919a11e593a
update-alternatives for gcc on Ubuntu · GitHub
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 7 --slave /usr/bin/g++ g++ /usr/bin/g++-7 --slave /usr/bin/gcov gcov /usr/bin/gcov-7 $ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 8 --slave /usr/bin/g++ g++ /usr/bin/g++-8 --slave /usr/bin/gcov gcov /usr/bin/gcov-8 $ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 9 --slave /usr/bin/g++ g++ /usr/bin/g++-9 --slave /usr/bin/gcov gcov /usr/bin/gcov-9 $ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10 $ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 11 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11 $ sudo update-alternatives --config gcc There are 2 choices for the alternative gcc (providing /usr/bin/gcc).
🌐
WinLibs
winlibs.com
WinLibs - GCC+MinGW-w64 compiler for Windows
WinLibs - MinGW-w64 personal build = GCC for Windows 32-bit and 64-bit - Coming soon: the largest collection of open source libraries ported to Windows using MinGW-w64 and MSYS2.
🌐
Baeldung
baeldung.com › home › installation › how to install the latest version of gcc on ubuntu
How to Install the Latest Version of GCC on Ubuntu | Baeldung on Linux
November 17, 2024 - Learn about different ways to acquire and deploy the latest version of the GNU Compiler Collection package in Linux.
🌐
Linux Mint Forums
forums.linuxmint.com › board index › interests › programming & development
How to Update GCC Latest Version? - Linux Mint Forums
June 12, 2023 - gcc-11 --version gcc-11 (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0 Copyright (C) 2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions.
🌐
Grandstream Networks
grandstream.com › support › firmware
Firmware- Grandstream Networks
Learn about the GCC’s PBX solution and the upgrades available to expand its capacity. Learn More ... Grandstream’s Firewall Service provides regular updates and upgrades to ensure that your firewall is always utilizing the most current security protocols.
🌐
GNU
gcc.gnu.org
GCC, the GNU Compiler Collection - GNU Project
The GNU Compiler Collection includes front ends for C, C++, Objective-C, Objective-C++, Fortran, Ada, Go, D, Modula-2, COBOL, Rust, and Algol 68 as well as libraries for these languages (libstdc++,...). GCC was originally written as the compiler for the GNU operating system.
🌐
Microsoft Learn
learn.microsoft.com › en-us › microsoftteams › teams-client-bulk-install
Bulk deploy the Microsoft Teams desktop client - Microsoft Teams | Microsoft Learn
HKEY_CURRENT_USER\SOFTWARE\Policies\Microsoft\Office\16.0\Teams Value = CloudType value type = DWORD 1 = Commercial, 2 = GCC, 3 = GCCH, 4 = DOD, 7 = Gallatin
🌐
Reddit
reddit.com › r/cpp_questions › need help updating gcc/g++ from mingw
r/cpp_questions on Reddit: Need help updating GCC/G++ from MinGW
October 17, 2023 -

Hello, I installed the compilers about a month ago with MingGW, little did I know they were out of date, around version 6. I can't find a good tutorial on how to update them on windows so if someone could help me out that would be great.

🌐
Visual Studio Code
code.visualstudio.com › docs › cpp › config-mingw
Using GCC with MinGW
November 3, 2021 - You have to reopen any console windows for the updated PATH environment variable to be available. To check that your MinGW-w64 tools are correctly installed and available, open a new Command Prompt and type: ... You should see output that states which versions of GCC, g++ and GDB you have installed.