How to Install GCC on Linux Mint 22 and 21

Last updated Tuesday, March 24, 2026 2:32 pm Joshua James 9 min read 2 comments

Most Linux Mint development work does not need a separate compiler download, because APT already handles the standard toolchain cleanly. To install GCC on Linux Mint, the quickest path is sudo apt install build-essential, which also installs g++, make, and the headers most common C and C++ projects expect.

Mint 22 ships GCC 13 as the default compiler and offers GCC 14 as an extra package, while Mint 21 ships GCC 11 by default and tops out at GCC 12 through APT. The same workflow can cover Mint’s packaged toolchain, newer patch releases from the Ubuntu Toolchain PPA, version switching with update-alternatives, and a source-built GCC 15.2.0 toolchain when the distro packages are not new enough.

Install GCC on Linux Mint

Start with the normal package-managed path unless you already know you need a newer upstream release or custom configure flags.

Update Linux Mint before installing GCC

Refresh the package index first so the compiler packages and dependency metadata match your current Mint release.

sudo apt update && sudo apt upgrade

These commands use sudo for tasks that need root privileges. If your account does not have sudo access yet, follow the guide on how to create and add users to sudoers on Linux Mint.

Three install paths cover the usual GCC scenarios on Linux Mint.

MethodGCC VersionsBest ForTrade-offs
Default APT packagesMint 22.x: GCC 9 through 14; Mint 21.x: GCC 9 through 12Most development work, distro-tested builds, versioned GCC packagesMint 21 cannot reach GCC 13 or newer through packages
Ubuntu Toolchain PPANewer patch releases for the packaged GCC branchesDevelopers who want newer fixes without moving to a source buildDoes not unlock new major GCC branches on Mint 21
Source buildLatest upstream release, validated here with GCC 15.2.0Mint 21 users who need GCC 13+, custom prefixes, or newer upstream featuresLonger build time, manual maintenance, separate runtime library path
  • Use the default APT packages when you want the simplest and safest GCC install on Linux Mint.
  • Use the Ubuntu Toolchain PPA only when you want newer patch releases for the same GCC branches Mint already packages.
  • Use the source-build path when Mint 21 needs GCC 13 or newer, or when you want a custom upstream toolchain outside Mint’s package database.

Mint 22 already gives you GCC 14 through the default repositories, so the Toolchain PPA is mostly about newer patch releases there. Mint 21 stops at GCC 12 in APT, and the Toolchain PPA does not change that major-version ceiling.

Install the default GCC toolchain on Linux Mint

build-essential is the normal starting point because it installs the C compiler, the g++ C++ compiler, Make, and the standard development package set in one step.

sudo apt install build-essential

Check the installed compiler and confirm that Mint is still using the package-managed binary under /usr/bin/gcc.

gcc --version
which gcc

Linux Mint 22.x output:

gcc (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0
Copyright (C) 2023 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.

/usr/bin/gcc

Linux Mint 21.x output:

gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0
Copyright (C) 2021 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.

/usr/bin/gcc

The package suffix after the version number may change with security or bug-fix updates, but the key checks stay the same: GCC runs, and the binary lives under /usr/bin/gcc.

Install versioned GCC packages on Linux Mint

Install versioned gcc-NN and g++-NN packages when one project needs a newer or older compiler than Mint’s default.

Linux Mint 22.x

sudo apt install gcc-14 g++-14
sudo apt install gcc-13 g++-13
sudo apt install gcc-12 g++-12
sudo apt install gcc-11 g++-11

Linux Mint 21.x

sudo apt install gcc-12 g++-12
sudo apt install gcc-11 g++-11
sudo apt install gcc-10 g++-10
sudo apt install gcc-9 g++-9

Verify the versioned compiler directly instead of assuming the unversioned gcc command has changed.

Linux Mint 22.x example

gcc-14 --version
gcc-14 (Ubuntu 14.2.0-4ubuntu2~24.04.1) 14.2.0

Linux Mint 21.x example

gcc-12 --version
gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04.3) 12.3.0

Add the Ubuntu Toolchain PPA for GCC patch updates

The Ubuntu Toolchain PPA is optional on Linux Mint. It does not add GCC 13 or 14 to Mint 21, but it can move the existing packaged branches to newer patch levels.

If add-apt-repository is missing on a minimal or stripped-down Mint system, install the helper first.

sudo apt install software-properties-common

Add the PPA, then refresh package metadata before checking the candidate versions.

sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa -y
sudo apt update

On Mint 22.x, relevant output includes the Launchpad fetch lines for the new source. Mint 21 shows the same Launchpad path with jammy in place of noble.

Get:10 https://ppa.launchpadcontent.net/ubuntu-toolchain-r/ppa/ubuntu noble InRelease [24.3 kB]
Get:13 https://ppa.launchpadcontent.net/ubuntu-toolchain-r/ppa/ubuntu noble/main i386 Packages [182 kB]
Get:20 https://ppa.launchpadcontent.net/ubuntu-toolchain-r/ppa/ubuntu noble/main amd64 Packages [256 kB]

Verify what the PPA actually changed. On Mint 22, checking gcc-14 is the quickest proof. On Mint 21, check gcc-12 because GCC 13 and 14 still are not packaged there.

Linux Mint 22.x example

apt-cache policy gcc-14
gcc-14:
  Installed: 14.2.0-4ubuntu2~24.04.1
  Candidate: 14.3.0-12ubuntu1~24~ppa1

Linux Mint 21.x example

apt-cache policy gcc-12
gcc-12:
  Installed: 12.3.0-1ubuntu1~22.04.3
  Candidate: 12.5.0-8ubuntu1~22~ppa1

If you only needed the PPA for a newer patch level, install the updated package with the same versioned commands from the earlier section. If you were hoping for GCC 13 or 14 on Mint 21, skip the PPA and move straight to the source-build method below.

Compile GCC from Source on Linux Mint

Source compilation is the practical path when Mint’s packaged branches are not new enough, especially on Mint 21 where APT stops at GCC 12. It also lets you keep a custom upstream compiler under its own prefix instead of replacing Mint’s packaged toolchain.

The validated workflow here builds GCC 15.2.0 with C and C++ support under /usr/local/15.2.0. Expect the build to take a while and keep at least 4 to 6 GB of free space available under your home directory while the compile runs.

Install GCC source-build dependencies on Linux Mint

Install the full dependency set first so configure and download_prerequisites can finish without missing-library errors.

sudo apt install build-essential flex bison libgmp3-dev libmpc-dev libmpfr-dev libisl-dev texinfo curl wget xz-utils

Detect the latest GCC release on Linux Mint

Run the next blocks in the same terminal session so the version, archive, and prefix variables stay available for the download and build steps. The detection line uses the curl command in Linux to read the GNU index and grep command examples in Linux to pull the newest GCC directory name.

GCC_VERSION=$(curl -fsSL https://ftp.gnu.org/gnu/gcc/ | grep -oE 'gcc-[0-9]+\.[0-9]+\.[0-9]+' | sort -Vu | tail -n1 | sed 's/^gcc-//')
PREFIX="/usr/local/$GCC_VERSION"
ARCHIVE="gcc-$GCC_VERSION.tar.xz"
URL="https://ftp.gnu.org/gnu/gcc/gcc-$GCC_VERSION/$ARCHIVE"

printf 'Latest GCC release: %s\nInstall prefix: %s\nArchive URL: %s\n' "$GCC_VERSION" "$PREFIX" "$URL"

Expected output:

Latest GCC release: 15.2.0
Install prefix: /usr/local/15.2.0
Archive URL: https://ftp.gnu.org/gnu/gcc/gcc-15.2.0/gcc-15.2.0.tar.xz

Download and prepare the GCC source tree on Linux Mint

Download the archive, extract it under your home directory, and let GCC fetch the extra math libraries its build expects.

mkdir -p "$HOME/gcc-source-test"
cd "$HOME/gcc-source-test"
curl -fsSLO "$URL"
tar -xf "$ARCHIVE"
cd "gcc-$GCC_VERSION"
./contrib/download_prerequisites
mkdir -p build

Configure GCC on Linux Mint

Use an out-of-tree build directory so the unpacked source stays clean. The --disable-bootstrap flag cuts build time on smaller Mint systems by skipping GCC’s self-hosting validation pass, which is a reasonable trade-off for a local custom toolchain.

cd "$HOME/gcc-source-test/gcc-$GCC_VERSION/build"
../configure --prefix="$PREFIX" --disable-multilib --enable-languages=c,c++ --disable-bootstrap

Build and install GCC on Linux Mint

The example below uses -j2 because it behaves safely on smaller Mint VMs. Raise the job count only if you know your machine has the spare CPU and memory for a heavier compile.

cd "$HOME/gcc-source-test/gcc-$GCC_VERSION/build"
make -j2
sudo make install

Register the custom runtime library directory next so binaries built with this GCC release can find the matching libstdc++ and related libraries.

printf '%s\n' "$PREFIX/lib64" | sudo tee "/etc/ld.so.conf.d/$GCC_VERSION.conf" > /dev/null
sudo ldconfig

Verify the custom compiler by calling it through the full path instead of replacing Mint’s package-managed /usr/bin/gcc.

"$PREFIX/bin/gcc" --version
"$PREFIX/bin/g++" --version

Expected output:

gcc (GCC) 15.2.0
g++ (GCC) 15.2.0

Create a quick hello-world test with the custom compiler if you want to prove the new toolchain is usable before you point a real project at it.

cat <<'EOF' > hello-source.c
#include <stdio.h>

int main(void) {
    printf("hello from gcc 15.2.0\n");
    return 0;
}
EOF

"$PREFIX/bin/gcc" hello-source.c -o hello-source
./hello-source

Expected output:

hello from gcc 15.2.0

Create a GCC update script on Linux Mint

If you plan to keep tracking upstream GCC releases, save a reusable helper under /usr/local/bin/update-gcc-source instead of rebuilding from scratch from memory a few months from now.

Run this helper manually after checking the GCC release notes. Do not schedule it in cron, because source-built compiler upgrades deserve a quick review before they replace your current custom toolchain.

This helper lives under /usr/local/bin, so the pipeline uses sudo tee because plain > redirection would not write to a root-owned path.

cat <<'EOF' | sudo tee /usr/local/bin/update-gcc-source > /dev/null
#!/bin/bash
set -e

BUILD_ROOT="$HOME/gcc-source-test"
LATEST=$(curl -fsSL https://ftp.gnu.org/gnu/gcc/ | grep -oE 'gcc-[0-9]+\.[0-9]+\.[0-9]+' | sort -Vu | tail -n1 | sed 's/^gcc-//')
PREFIX="/usr/local/$LATEST"
ARCHIVE="gcc-$LATEST.tar.xz"
URL="https://ftp.gnu.org/gnu/gcc/gcc-$LATEST/$ARCHIVE"

for cmd in curl tar make gcc; do
    command -v "$cmd" > /dev/null 2>&1 || {
        echo "Missing required command: $cmd"
        exit 1
    }
done

if [ -x "$PREFIX/bin/gcc" ]; then
    echo "GCC $LATEST is already installed at $PREFIX"
    exit 0
fi

echo "Building GCC $LATEST under $BUILD_ROOT"
mkdir -p "$BUILD_ROOT"
cd "$BUILD_ROOT"
rm -rf "gcc-$LATEST" "$ARCHIVE"
curl -fsSLO "$URL"
tar -xf "$ARCHIVE"
cd "gcc-$LATEST"
./contrib/download_prerequisites
mkdir -p build
cd build
../configure --prefix="$PREFIX" --disable-multilib --enable-languages=c,c++ --disable-bootstrap
make -j2
sudo make install
printf '%s\n' "$PREFIX/lib64" | sudo tee "/etc/ld.so.conf.d/$LATEST.conf" > /dev/null
sudo ldconfig
echo "Installed GCC $LATEST at $PREFIX"
EOF

sudo chmod 0755 /usr/local/bin/update-gcc-source

Verify that the helper is reachable from your shell before you rely on it later.

command -v update-gcc-source

Expected output:

/usr/local/bin/update-gcc-source

Switch GCC Versions on Linux Mint

Install the versioned packages you need first, then let update-alternatives manage which unversioned gcc, g++, and gcov commands are active.

Register GCC versions with update-alternatives on Linux Mint

Keep the slave list limited to g++ and gcov. Leaving cpp out avoids conflicts with Mint’s separate preprocessor alternative.

Linux Mint 22.x

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
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 130 --slave /usr/bin/g++ g++ /usr/bin/g++-13 --slave /usr/bin/gcov gcov /usr/bin/gcov-13

Linux Mint 21.x

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 120 --slave /usr/bin/g++ g++ /usr/bin/g++-12 --slave /usr/bin/gcov gcov /usr/bin/gcov-12
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 110 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11

Switch the default GCC version on Linux Mint

Use the interactive selector when you want to change the default compiler for the current machine.

sudo update-alternatives --config gcc

Linux Mint 22.x output:

There are 2 choices for the alternative gcc (providing /usr/bin/gcc).

  Selection    Path             Priority   Status
------------------------------------------------------------
* 0            /usr/bin/gcc-14   140       auto mode
  1            /usr/bin/gcc-13   130       manual mode
  2            /usr/bin/gcc-14   140       manual mode

Press <enter> to keep the current choice[*], or type selection number:

Confirm the active compiler afterward with a normal version check.

gcc --version

Test GCC on Linux Mint

A short compile-and-run test is still the fastest way to prove that GCC, the linker, and your shell all agree on the same toolchain.

Create a GCC test program on Linux Mint

Write a tiny C source file in the current directory.

cat <<'EOF' > hello.c
#include <stdio.h>

int main(void) {
    puts("Hello from GCC!");
    return 0;
}
EOF

Compile and run the GCC test on Linux Mint

Compile the file, run the binary, and remove the test files when you are done.

gcc hello.c -o hello
./hello
rm hello.c hello

Expected output:

Hello from GCC!

Troubleshoot GCC on Linux Mint

Most GCC issues on Linux Mint come down to package availability on Mint 21, alternative-registration mistakes, or a missing runtime library path after a source build.

Fix "Unable to locate package gcc-14" on Linux Mint 21

Mint 21 inherits Ubuntu 22.04 package availability, so GCC 13 and 14 are not packaged there through either the default repositories or the Toolchain PPA.

apt-cache search '^gcc-[0-9]+$' | sort

Relevant output on Mint 21 includes only the versioned packages from gcc-9 through gcc-12. If you need a newer major branch there, use the source-build method or move to Mint 22.

gcc-10 - GNU C compiler
gcc-11 - GNU C compiler
gcc-12 - GNU C compiler
gcc-9 - GNU C compiler

Fix GCC version switching issues on Linux Mint

If update-alternatives complains that cpp is already a master alternative, keep cpp out of the slave list and register only gcc, g++, and gcov.

update-alternatives: error: alternative cpp can't be slave of gcc: it is a master alternative
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

Fix GCC source build failures on Linux Mint

Recheck the dependency list and free disk space first, because most failed GCC builds on Mint break before or during configure when one of the math libraries is missing.

sudo apt install build-essential flex bison libgmp3-dev libmpc-dev libmpfr-dev libisl-dev texinfo curl wget xz-utils
df -h "$HOME/gcc-source-test"

Keep at least 4 to 6 GB of free space available in the build area before you start another compile.

Fix source-built GCC runtime library errors on Linux Mint

If a binary built with the custom toolchain fails with a missing libstdc++.so.6 or similar runtime error, refresh the source-built library path and rebuild the linker cache.

GCC_VERSION=15.2.0
printf '%s\n' "/usr/local/$GCC_VERSION/lib64" | sudo tee "/etc/ld.so.conf.d/$GCC_VERSION.conf" > /dev/null
sudo ldconfig
./program: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version 'CXXABI_1.3.15' not found

Remove GCC Versions on Linux Mint

Most systems should keep Mint’s stock compiler in place. In practice, removal usually means cleaning up an extra version, removing the optional Toolchain PPA, or deleting a source-built toolchain you no longer need.

Remove extra APT-installed GCC versions on Linux Mint

Remove only the versioned packages you added manually. If you registered them with update-alternatives, remove the alternative entry first so Mint does not keep a dead path as the selected gcc target.

Linux Mint 22.x example

sudo update-alternatives --remove gcc /usr/bin/gcc-14
sudo apt remove gcc-14 g++-14

Linux Mint 21.x example

sudo update-alternatives --remove gcc /usr/bin/gcc-12
sudo apt remove gcc-12 g++-12

Review sudo apt autoremove manually after the package removal if you want to clean up orphaned dependencies. On reused development systems, an automatic autoremove can remove more packages than you intended.

Verify that the package is no longer installed while the repository candidate still exists.

Linux Mint 22.x example

apt-cache policy gcc-14
gcc-14:
  Installed: (none)
  Candidate: 14.2.0-4ubuntu2~24.04.1

Linux Mint 21.x example

apt-cache policy gcc-12
gcc-12:
  Installed: (none)
  Candidate: 12.3.0-1ubuntu1~22.04.3

Remove the Ubuntu Toolchain PPA on Linux Mint

Remove the PPA after you have moved back to Mint’s repository builds or decided the extra patch updates are not worth keeping.

sudo add-apt-repository --remove ppa:ubuntu-toolchain-r/ppa -y
sudo apt update

Check the versioned package that matches your release to make sure the candidate has dropped back to Mint’s normal repository version.

Linux Mint 22.x example

apt-cache policy gcc-14
gcc-14:
  Candidate: 14.2.0-4ubuntu2~24.04.1

Linux Mint 21.x example

apt-cache policy gcc-12
gcc-12:
  Candidate: 12.3.0-1ubuntu1~22.04.3

Remove source-built GCC on Linux Mint

Remove the source-built tree only after you confirm Mint’s packaged /usr/bin/gcc still works for the projects you care about. The commands below delete the custom install prefix, its linker entry, the build tree, and the optional update helper.

GCC_VERSION=15.2.0
sudo rm -rf "/usr/local/$GCC_VERSION"
sudo rm -f "/etc/ld.so.conf.d/$GCC_VERSION.conf"
sudo ldconfig
rm -rf "$HOME/gcc-source-test/gcc-$GCC_VERSION"
sudo rm -f /usr/local/bin/update-gcc-source

Verify that the custom compiler path is gone.

GCC_VERSION=15.2.0
if [ -x "/usr/local/$GCC_VERSION/bin/gcc" ]; then echo present; else echo removed; fi

Expected output:

removed

GCC on Linux Mint FAQ

Does build-essential install the C++ compiler on Linux Mint?

Yes. build-essential installs the standard development stack, including gcc, g++, make, and related headers. If you need a newer C++ compiler than Mint’s default, install a versioned package such as g++-14 on Mint 22 or g++-12 on Mint 21.

Should I download GCC manually on Linux Mint?

Usually, no. The normal Linux Mint path is sudo apt install build-essential or a versioned gcc-NN package. A manual source download only makes sense when you need a newer upstream release than Mint packages provide or you want custom configure flags.

Why does Linux Mint 21 stop at GCC 12 in APT?

Linux Mint 21 is based on Ubuntu 22.04, and that package base stops at GCC 12. The Ubuntu Toolchain PPA can raise the patch level for that branch, but it does not add GCC 13 or 14 to Mint 21. For GCC 13 or newer there, use the source-build method or move to Mint 22.

How do I change the default GCC version on Linux Mint?

Install the versioned compiler packages you need, register them with update-alternatives, and then run sudo update-alternatives --config gcc. That switch changes the active gcc, g++, and gcov set together when you use the slave options shown in the article.

Conclusion

GCC is now installed on Linux Mint with a clear path for distro packages, versioned compilers, and a newer upstream source build when Mint’s repositories are not enough. From here, install Git on Linux Mint for version control, install VS Code on Linux Mint for editing and debugging, or install Rust on Linux Mint if you also work across newer systems programming toolchains.

Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffee Buy me a coffee

2 thoughts on “How to Install GCC on Linux Mint 22 and 21”

Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed in published comments:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<blockquote>quote</blockquote> quote block

Got a Question or Feedback?

We read and reply to every comment - let us know how we can help or improve this guide.

Let us know you are human: