Yes, absolutely 🙂 — you can install newer GCC versions on Ubuntu. By default, Ubuntu’s repositories usually lag a bit behind, but you have a few options depending on how bleeding-edge you want to go.


🔹 1. Check your current GCC version

gcc --version

Ubuntu 22.04 ships with GCC 11, and Ubuntu 24.04 with GCC 13. If you need GCC 14 (for -std=c23), you’ll need to add a newer repo or build it.


🔹 2. Install from Ubuntu Toolchain PPA (recommended)

Ubuntu has an official Toolchain Test Builds PPA maintained by Ubuntu developers.

sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install gcc-14 g++-14

Now you’ll have gcc-14 and g++-14 alongside your default compiler.

You can check:

gcc-14 --version

🔹 3. Switch between versions

If you want gcc to point to the new version:

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

Then select the version:

sudo update-alternatives --config gcc


🔹 4. Build GCC from source (last resort)