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.

🌐
Ubuntu
documentation.ubuntu.com › ubuntu-for-developers › reference › availability › gcc
Available GCC versions - Ubuntu for Developers
April 5, 2026 - GCC versions available in Ubuntu releases from 14.04 to the current development series.
🌐
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-
🌐
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 - Before checking out the step-by-step process, let’s note that the Ubuntu Universe repository contains GCC-14 (14.2.0, specifically), which is the latest version available.
🌐
Reddit
reddit.com › r/ubuntu › install gcc 14 in non-debug mode in ubuntu 24.04
r/Ubuntu on Reddit: Install GCC 14 in non-debug mode in Ubuntu 24.04
July 29, 2024 - Ubuntu 24.04's gcc-14 is configured with --enable-checking=yes,extra,rtl so indeed it's a debug build, not a release build.
🌐
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 - GCC 14 has several new usability improvements. Although GCC 15 is already available, many systems still do not have it available in the package manager repositories, but GCC 14 does! Like in Ubuntu, for example.
Find elsewhere
🌐
Ubuntu
packages.ubuntu.com › noble › gcc-14-base
Ubuntu – Details of package gcc-14-base in noble
Download Source Package gcc-14: [gcc-14_14.2.0-4ubuntu2~24.04.dsc] [gcc-14_14.2.0.orig.tar.gz] [gcc-14_14.2.0-4ubuntu2~24.04.debian.tar.xz] Maintainer: Ubuntu Core developers (Mail Archive) · Please consider filing a bug or asking a question via Launchpad before contacting the maintainer directly
🌐
Ubuntu
packages.ubuntu.com › noble › gcc-14
Ubuntu – Details of package gcc-14 in noble
dep: gcc-14-base (= 14-20240412-0ubuntu1) [not amd64, i386] GCC, the GNU Compiler Collection (base package) dep: gcc-14-base (= 14.2.0-4ubuntu2~24.04) [amd64, i386] dep: gcc-14-i686-linux-gnu (= 14.2.0-4ubuntu2~24.04) [i386] GNU C compiler for the i686-linux-gnu architecture ·
🌐
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 - The system confirms GCC version 14.2.0 is installed. ... This guide showed how to install the GCC compiler on Ubuntu using three different methods.
🌐
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 registers cpp separately by default. Solution: Drop cpp from the slave list and only tie g++ and gcov to gcc. This approach works because gcc invokes the correct preprocessor internally without needing cpp as an explicit slave: sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 140 \ --slave /usr/bin/g++ g++ /usr/bin/g++-14 \ --slave /usr/bin/gcov gcov /usr/bin/gcov-14
🌐
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 - In my case, g++ 14 was not available via apt, so I had to download and build it manually. (See below.) sudo apt update apt search "^gcc-[0-9]" apt search "^g\\+\\+-[0-9]"
🌐
GitHub
gist.github.com › martin-kokos › 78e60f126c86ec68f540d23f025455b5
Install gcc-14 and distcc on Ubuntu · GitHub
apt install software-properties-common # installs apt-add-repository # apt-add-repository ppa:ubuntu-toolchain-r/test apt-add-repository universe apt update apt install gcc-14 g++-14 ll /usr/bin/gcc-14 ll /usr/bin/g++-14 update-alternatives --display gcc ll /etc/alternatives/g* update-alternatives --remove-all gcc update-alternatives --remove-all g++ update-alternatives --install /usr/bin/gcc gcc /usr/bin/g++-14 10 update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 10 g++ --version gcc --version
🌐
UbuntuUpdates
ubuntuupdates.org › package › core › noble › main › base › gcc-14
UbuntuUpdates - Package "gcc-14" (noble 24.04)
UbuntuUpdates.org · Raw Package Information · All versions of this package · Bug fixes · List of files in package · Repository home page · Deleted packages are displayed in grey. gcc-14-base · There is no recent update for this package. About - Send Feedback to @ubuntu_updates ·
🌐
CyberPanel
cyberpanel.net › blog › install-gcc-on-ubuntu
How To Install GCC On Ubuntu: Easiest Methods Explained!
February 2, 2026 - ./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 · Check the official GNU GCC configuration page for more options and recommended configurations. 7. Start the GCC build process using the make command: ... This process can be resource-intensive and may take some time. The j3 option tells the system to use three cores for the build. Adjust the number of CPU cores based on your system’s specifications. 8. Once the build is finished, install GCC with this command: ... gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609 Copyright (C) 2015 Free Software Foundation, Inc.
🌐
Ubuntu
launchpad.net › ubuntu › trusty › +package › gcc
gcc : Trusty (14.04) : Ubuntu - Launchpad
Trusty (14.04) gcc · This is the GNU C compiler, a fairly portable optimizing compiler for C. . This is a dependency package providing the default GNU C compiler. gcc-defaults 1.124ubuntu6 source package in Ubuntu ·
🌐
Ubuntu
security.ubuntu.com › ubuntu › pool › main › g › gcc-14
Index of /ubuntu/pool/main/g/gcc-14
Index of /ubuntu/pool/main/g/gcc-14 · Apache/2.4.52 (Ubuntu) Server at security.ubuntu.com Port 443