I'm still on Ubuntu 22.04 LTS but needed g++14. The sudo apt-get gcc-14 did not work for me, as it installed clang++14 for some reason (perhaps a misconfiguration on my part). What did work for me was following the instructions I found at https://www.dedicatedcore.com/blog/install-gcc-compiler-ubuntu/

The steps I took:

sudo apt install build-essential
sudo apt install libmpfr-dev libgmp3-dev libmpc-dev -y
wget https://ftp.gnu.org/gnu/gcc/gcc-14.1.0/gcc-14.1.0.tar.gz
tar -xf gcc-14.1.0.tar.gz
cd gcc-14.1.0
./configure -v --build=$(uname -m)-linux-gnu --host=$(uname -m)-linux-gnu --target=$(uname -m)-linux-gnu --prefix=/usr/local/gcc-14.1.0 --enable-checking=release --enable-languages=c,c++ --disable-multilib --program-suffix=-14.1.0
make
sudo make install

And if you would like to make it the default:

sudo update-alternatives --install /usr/bin/g++ g++ /usr/local/gcc-14.1.0/bin/g++-14.1.0 14
sudo update-alternatives --install /usr/bin/gcc gcc /usr/local/gcc-14.1.0/bin/gcc-14.1.0 14

After that, g++ showed I was running version 14.1.0. I was then able to compile my project that included some c++20/23 features that were not in the previous versions of g++ (chrono/format).

Answer from John Jones on askubuntu.com
Top answer
1 of 5
20

I'm still on Ubuntu 22.04 LTS but needed g++14. The sudo apt-get gcc-14 did not work for me, as it installed clang++14 for some reason (perhaps a misconfiguration on my part). What did work for me was following the instructions I found at https://www.dedicatedcore.com/blog/install-gcc-compiler-ubuntu/

The steps I took:

sudo apt install build-essential
sudo apt install libmpfr-dev libgmp3-dev libmpc-dev -y
wget https://ftp.gnu.org/gnu/gcc/gcc-14.1.0/gcc-14.1.0.tar.gz
tar -xf gcc-14.1.0.tar.gz
cd gcc-14.1.0
./configure -v --build=$(uname -m)-linux-gnu --host=$(uname -m)-linux-gnu --target=$(uname -m)-linux-gnu --prefix=/usr/local/gcc-14.1.0 --enable-checking=release --enable-languages=c,c++ --disable-multilib --program-suffix=-14.1.0
make
sudo make install

And if you would like to make it the default:

sudo update-alternatives --install /usr/bin/g++ g++ /usr/local/gcc-14.1.0/bin/g++-14.1.0 14
sudo update-alternatives --install /usr/bin/gcc gcc /usr/local/gcc-14.1.0/bin/gcc-14.1.0 14

After that, g++ showed I was running version 14.1.0. I was then able to compile my project that included some c++20/23 features that were not in the previous versions of g++ (chrono/format).

2 of 5
16

GCC-14 (and G++-14) is available in the Universe repository for Ubuntu 24.04, as evident in the Ubuntu Package archive.

It is equally evident that this package is not available for Ubuntu 22.04, so installing this on 22.04 will require some third-party interference, or you have to compile it yourself.

See here on how to enable the Universe repositories.

🌐
DEV Community
dev.to › marcosplusplus › how-to-install-gcc-14-and-use-c23-41od
How to Install GCC 14 and Use C++23 - DEV Community
April 15, 2025 - g++ --version g++ (Ubuntu 14.2.0-4ubuntu2~24.04) 14.2.0 Copyright (C) 2024 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. Advantages of doing it the way above instead of just changing the symbolic link: Doesn't break the system. Can easily switch between versions. Avoids conflicts with apt/dpkg. If you are having problems with your LSP clangd also install these libraries for compatibility with Clang:
🌐
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 - $ ./configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/usr/local/gcc-14.2.0 --enable-checking=release \ --enable-languages=c,c++ --disable-multilib --program-suffix=-14.2.0 Command completed successfully. The last line suggests that the machine is ready for the installation.
🌐
GNU
gcc.gnu.org › install
Installing GCC - GNU Project
The latest version of this document is always available at https://gcc.gnu.org/install/. It refers to the current development sources, instructions for specific released versions are included with the sources.
🌐
GNU
gcc.gnu.org › gcc-14
GCC 14 Release Series - GNU Project
May 23, 2025 - To obtain GCC please use our mirror sites or our version control system.
🌐
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 - sudo apt install libmpfr-dev libgmp3-dev libmpc-dev -y · 3. Use the wget command to download the GCC source code from the GCC website. In this example, the file gcc-14.2.0.tar.gz contains the source code for GCC version 14.2.0:
🌐
Ubuntu
packages.ubuntu.com › noble › gcc-14-x86-64-linux-gnu
Ubuntu – Details of package gcc-14-x86-64-linux-gnu in noble
Download Source Package gcc-14-cross: [gcc-14-cross_4ubuntu3.3.dsc] [gcc-14-cross_4ubuntu3.3.tar.xz] Ubuntu Developers (Mail Archive) Please consider filing a bug or asking a question via Launchpad before contacting the maintainer directly. Debian GCC Maintainers (Mail Archive) Matthias Klose ·
Find elsewhere
🌐
Debian
packages.debian.org › sid › gcc-14
Debian -- Details of package gcc-14 in sid
dep: cpp-14 (= 14.3.0-16) [not ia64, ppc64, riscv64, sh4, x32] dep: gcc-14-aarch64-linux-gnu (= 14.3.0-16) [arm64] GNU C compiler for the aarch64-linux-gnu architecture · dep: gcc-14-alpha-linux-gnu (= 14.3.0-16) [alpha] GNU C compiler for the alpha-linux-gnu architecture ·
🌐
Ask Ubuntu
askubuntu.com › questions › 1541622 › how-to-install-gcc-14-and-g-14-on-ubuntu-22-04
apt - How to install gcc-14 and g++-14 on Ubuntu 22.04? - Ask Ubuntu
February 17, 2025 - sudo ln -s /usr/local/gcc-14/bin/g++ /usr/local/bin/g++-14 sudo ln -s /usr/local/gcc-14/bin/gcc /usr/local/bin/gcc-14 ... Alternatively, you can do something similar with update-alternatives. sudo update-alternatives --install /usr/bin/g++ g++ ...
🌐
LinuxCapable
linuxcapable.com › home › ubuntu › how to install gcc on ubuntu 26.04, 24.04 and 22.04
How to Install GCC on Ubuntu 26.04, 24.04 and 22.04 - LinuxCapable
April 30, 2026 - Ubuntu 26.04 provides GCC 11 through GCC 16 in the default repositories, Ubuntu 24.04 provides GCC 9 through GCC 14 by default, and Ubuntu 22.04 needs the Toolchain Test PPA for GCC 13 and newer. ... Replace gcc-15 g++-15 with the branch you need. If the candidate is empty after adding the correct repository, recheck your Ubuntu release and the package matrix near the start of this article before trying to install the package.
🌐
Linux From Scratch
linuxfromscratch.org › blfs › view › 12.3 › general › gcc.html
GCC-14.2.0
To install them, you can proceed ... after installing the corresponding compiler from a binary package, adding ada or d to the --enable-languages line. This package is known to build and work properly using an LFS 12.3 platform. If you are upgrading GCC from any other version prior to 14.2.0, ...
🌐
Debian
packages.debian.org › gcc-14
Debian -- Package Search Results -- gcc-14
sid (unstable) (devel): GNU C compiler for the alpha-linux-gnu architecture 14.3.0-12 [debports]: alpha 14.3.0-8cross1: amd64 arm64 i386 ppc64el x32 · trixie (stable) (devel): GCC, the GNU Compiler Collection (base package) 14.2.0-19cross1: amd64 arm64 i386 ppc64el
🌐
Ubuntu
launchpad.net › ubuntu › +source › gcc-14
gcc-14 package in Ubuntu
gnueabihf g++-14-for-build: GNU C++ compiler for the build architecture g++-14-for-host: GNU C++ compiler for the host architecture g++-14- ... gnueabihf gcc-14-base: GCC, the GNU Compiler Collection (base package) gcc-14-doc: Documentation for the GNU compilers (gcc, gobjc, g++) gcc-14-for-build: GNU C compiler for the build architecture gcc-14-for-host: GNU C compiler for the host architecture gcc-14-
🌐
GitHub
gist.github.com › application2000 › 73fd6f4bf1be6600a2cf9f56315a2d91
How to install latest gcc on Ubuntu LTS (12.04, 14.04, 16.04) · GitHub
GCC 9.1.0 on Ubuntu 14.04 & 16.04 & 18.04: sudo apt-get update -y && sudo apt-get upgrade -y && sudo apt-get dist-upgrade -y && sudo apt-get install build-essential software-properties-common -y && sudo add-apt-repository ppa:ubuntu-toolchain-r/test ...
🌐
Quora
quora.com › How-do-I-install-GCC-4-9-0-in-Ubuntu-14-04-LTS-to-compile-C++
How to install GCC 4.9.0 in Ubuntu 14.04 LTS to compile C++ - Quora
Answer (1 of 9): Thank you for asking this question, it helped me a lot to recall all the stuff regarding Ubuntu. If you simply install GCC 4.9.0 in Ubuntu 14.04 definitely it will get install by using following lines of command but still system will not set it as your default compiler. [code]s...
🌐
Debian
packages.debian.org › sid › libs › gcc-14-base
Debian -- Details of package gcc-14-base in sid
Este paquete contiene los archivos comunes a todos los lenguajes y bibliotecas contenidos en la recopilación del compilador de GNU (GCC).
🌐
Homebrew
formulae.brew.sh › formula › gcc@14
gcc@14 — Homebrew Formulae
brew install gcc@14 · GNU compiler collection · https://gcc.gnu.org/ License: GPL-3.0-or-later WITH GCC-exception-3.1 · Development: Pull requests · Formula JSON API: /api/formula/gcc@14.json · Formula code: gcc@14.rb on GitHub ·
🌐
Debian
tracker.debian.org › pkg › gcc-14
gcc-14 - Debian Package Tracker
∙ ∙ Autopkgtest for gcc-14/14.3.0-16: amd64: Pass, arm64: Pass, i386: Pass, loong64: Failed (not a regression) ♻ (reference ♻), ppc64el: Pass, s390x: Pass
🌐
GNU
gcc.gnu.org › gcc-14 › porting_to.html
Porting to GCC 14 - GNU Project
Some of these changes are user visible and can cause grief when porting to GCC 14. This document is an effort to identify common issues and provide solutions.