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
🌐
Medium
medium.com › @ihouelecaurcy › how-to-check-and-install-gcc-on-linux-complete-developer-guide-98697e2ab78f
How to Check and Install GCC on Linux: Complete Developer Guide | by Ihouele Caurcy | Medium
July 24, 2025 - sudo dnf install gcc # Or install complete development tools sudo dnf groupinstall "Development Tools" ... # Check system headers ls /usr/include/stdio.h >/dev/null 2>&1 && \ echo "✅ Headers present" || \ echo "❌ Headers missing" # Debian/Ubuntu ...
🌐
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.
Discussions

Is installing GCC on Linux as complicated as I think it is?
Disclaimer: I am not well versed at Linux at all. Please pardon my ignorance. I'm trying to figure out how to install GCC onto my macbook running Ubuntu 16.04. However after reading through the 6 steps to install GCC outlined on the GCC website I am at a total loss. I understand maybe 50% of the words on these pages. There are so many prerequisites and so many software requirements and so many technical things you have to set up that there is basically no hope in ... More on reddit.com
🌐 r/learnprogramming
13
8
June 14, 2017
c++ - Install gcc on linux with no root privilege - Stack Overflow
You need both the gcc-core and gcc-g++ to generate the c++ compiler (or the complete[=largest] package). The missing install-sh is in the gcc-core package. 2010-07-09T12:26:49.547Z+00:00 ... linuxfromscratch.org/lfs/view/stable may be useful for how-to get g++ building. More on stackoverflow.com
🌐 stackoverflow.com
How can I run windows.h crap in Linux
Why would you need windows.h to learn C++? That header contains windows-specific stuff, which you need (only) when you want to do C++ programming *specifically for windows*. If that is what you want, get a windows machine. If not, remove the include, and if that gives you problems solve those, or abandon the example because it is windows-specific. More on reddit.com
🌐 r/cpp_questions
4
3
November 6, 2020
How to install avr-gcc 10.1.0 in Ubuntu?
I can only get 5.4.0 installing avr-gcc with sudo apt-get install. I've downloaded avr-gcc-10.1.0-x64-linux.tar.bz2 from here: https://blog.zakkemble.net/avr-gcc-builds/ but have no idea how to make my system actually use it. I'm a pretty new Linux user and suspect that this might be a fairly basic thing but can't find any information... More on reddit.com
🌐 r/avr
5
7
September 17, 2020
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
15

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.

🌐
GeeksforGeeks
geeksforgeeks.org › installation guide › how-to-install-gcc-compiler-on-linux
How to Install GCC Compiler on Linux? - GeeksforGeeks
July 23, 2025 - Command 2: Now we have to install the build-essential packages, which is also known as a meta-package, it contains the GCC compiler all the other essentials used to compile the software written in C and C++ language. ... It will take some time to install all the essential packages. Command 3: After the second command it will install GCC on your Linux, to verify it is installed correctly, check the version of the GCC.
🌐
iO Flood
ioflood.com › blog › install-gcc-command-linux
Installing and Using the GCC Command: Linux User Guide
January 2, 2024 - On RPM-based distributions, you can use sudo yum install glibc-devel. This error occurs when GCC can’t find the main function. In C, every program must have a main function as the entry point. gcc hello.c -o hello # Output: # '/usr/lib/gc...
🌐
Reddit
reddit.com › r/learnprogramming › is installing gcc on linux as complicated as i think it is?
r/learnprogramming on Reddit: Is installing GCC on Linux as complicated as I think it is?
June 14, 2017 - GCC and G++ are part of the GNU system (GCC stands for GNU C Compiler I'm pretty sure). Most people call GNU/Linux just "Linux" a lot of the time because almost all major distributions include the main GNU packages, but it's completely possible to have a Linux kernel without GNU or with just pieces of it. ... Depends on the distribution. Some include them as part of the base install, some don't.
Find elsewhere
🌐
Greenwebpage
greenwebpage.com › home › blog › how to install gcc compiler on linux
How to Install GCC Compiler on Linux - Greenwebpage Community
July 4, 2024 - The GCC compiler can be easily installed on any Linux distribution, including the Ubuntu 24.04 system. On Ubuntu, you can use the “sudo apt install build-essential -y” or “sudo apt install gcc -y” to install the GCC compiler.
🌐
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 needed to build software.
🌐
LinuxCapable
linuxcapable.com › home › linux mint › how to install gcc on linux mint 22 and 21
How to Install GCC on Linux Mint 22 and 21 - LinuxCapable
November 22, 2024 - To install GCC on Linux Mint, the quickest path is sudo apt install build-essential, which brings in gcc, the g++ C++ compiler, make, and the headers most common C and C++ projects expect.
🌐
UltaHost
ultahost.com › knowledge-base › install-gcc-compiler-linux
How to Install GCC Compiler on Linux | Ultahost Knowledge Base
September 3, 2024 - If you are using a less common distribution refer to its package manager for specific GCC compiler Linux download. The general approach is usually similar involving updating package lists and installing the GCC package.
🌐
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 - There are lots of GCC PPAs available on the Web. In this case, we use the ubuntu-toolchain-r/test PPA. So, let’s leverage the add-apt-repository command to add this PPA to the system: $ sudo add-apt-repository ppa:ubuntu-toolchain-r/test ... Now, let’s go ahead to the final step. Of course, after making the necessary preparations, we should be able to install GCC on the system:
🌐
LinuxConfig
linuxconfig.org › home › how to install gcc the c compiler on ubuntu 22.04 lts jammy jellyfish linux
How to install GCC the C compiler on Ubuntu 22.04 LTS Jammy Jellyfish Linux
January 8, 2024 - Although you can install the C compiler separately by installation of the gcc package, the recommended way to install the C compiler on Ubuntu 22.04 Jammy Jellyfish is by installation of the entire development package build-essential. Open a command line terminal and install C compiler by installation of the development package build-essential:
🌐
LinuxConfig
linuxconfig.org › home › how to install gcc the c compiler on ubuntu 18.04 bionic beaver linux
How to install GCC the C compiler on Ubuntu 18.04 Bionic Beaver Linux
September 22, 2025 - The following linux command will install gcc compiler on on Ubuntu 18.04 Bionic Beaver. Open up terminal and enter: ... Another way to install gcc compiler is to install it as part of build-essential package. build-essential package will also install additional libraries as well as g++ compiler. ...
🌐
Linuxize
linuxize.com › home › gcc › how to install gcc compiler on ubuntu 18.04
How to Install GCC Compiler on Ubuntu 18.04 | Linuxize
October 31, 2019 - Perform the steps below to install the GCC Compiler Ubuntu 18.04: ... The command installs a bunch of new packages including gcc, g++ and make.
🌐
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 - The apt package manager is the quickest way to install GCC on Ubuntu. Nevertheless. There are drawbacks to installing GCC from the Ubuntu repositories, including a lack of customization options and potential dependency conflicts.
🌐
GNU
gcc.gnu.org › install › configure.html
Installing GCC: Configuration - GNU Project
March 17, 2026 - On SH Linux systems, generate ELF FDPIC code. ... If you want to build GCC but do not have the GMP library, the MPFR library and/or the MPC library installed in a standard location and do not have their sources present in the GCC source tree then you can explicitly specify the directory where they are installed (‘--with-gmp=gmpinstalldir’, ‘--with-mpfr=mpfrinstalldir’, ‘--with-mpc=mpcinstalldir’).
🌐
Sorush Khajepor
iamsorush.com › posts › build-gcc11
Build GCC 11 from source on Ubuntu - Sorush Khajepor
Here I am building and installing the latest GCC, 11.1, on Ubuntu 21.04 from the source. The procedure is explained step by step.
🌐
Red Hat
developers.redhat.com › articles › 2023 › 11 › 10 › install-gcc-and-build-hello-world-application-rhel-9
Install GCC and build a Hello World application on RHEL 9 | Red Hat Developer
November 10, 2023 - Red Hat Enterprise Linux provides a comprehensive set of tools for developing C and C++ applications. Download and install the development tools package group, which includes GNU Compiler Collection (GCC), GNU Debugger (GDB), and other development tools: