Home » How-To » How to install GCC 11 on Ubuntu

How to install GCC 11 on Ubuntu

GCC can be used to compile C, C++, Objective C, and Objective C++ language .

GCC 11 is the current Development Tools Module complier in SUSE Linux Enterprise 15 SP3.

It aims on the essential optimization levels and options LTO and PGO.

In this guide, you’ll learn how to install GCC 11 on Ubuntu, test it, and uninstall it.

How to install GCC 11 on Ubuntu

To install GCC 11 on Ubuntu, you need to add the Toolchain repository and install GCC 11 by running this command, “sudo apt install -y gcc-11”.

Step 1: Add the Toolchain repository

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

Step 2: Install GCC 11 on Ubuntu

sudo apt install -y gcc-11

Step 3: Verify the GCC 11 version

gcc-11 --version

How to test GCC 11 on Ubuntu

To test GCC 11 on Ubuntu, you need to make a main.c file, copy and paste an example code, and compile the code, and run the program.

1. Make a main.c file

nano main.c

2. Copy and paste this code

int main() {

    return 0;

3. Compile a code

gcc-11 main.c -o test

4. Run the program


How to uninstall GCC 11 on Ubuntu

To uninstall GCC 11 on Ubuntu, you need to remove remove GCC 11 and related dependencies and remove the GCC repository and key by running some commands.

1. Remove GCC 11/related dependencies

sudo apt purge --autoremove -y gcc-11

2. Remove the GCC repository + key

sudo rm -rf /etc/apt/trusted.gpg.d/ubuntu-toolchain-r_ubuntu_test.gpg
sudo rm -rf /etc/apt/sources.list.d/ubuntu-toolchain-r-ubuntu-test-focal.list

Further reading

How to install jq on Ubuntu


How to Fix “python: can’t open file ‘manage.py’: [Errno 2] No such file or directory”

About the author

Lim How Wei

Lim How Wei is the founder of followchain.org, with 8+ years of experience in Social Media Marketing and 4+ years of experience as an active investor in stocks and cryptocurrencies. He has researched, tested, and written thousands of articles ranging from social media platforms to messaging apps.

Lim has been quoted and referenced by major publications and media companies like WikiHow, Fast Company, HuffPost, Vice, New York Post, The Conversation, and many others. One of his articles about the gig economy was quoted by Joe Rogan who hosts The Joe Rogan Experience (arguably the most popular podcast in the world), in the This Past Weekend podcast by Theo Von.

In his free time, Lim plays multiple games like Genshin Impact, League of Legends, Counter-Strike, Hearthstone, RuneScape, and many others. He creates guides, walkthroughs, solutions, and more on games that he plays to help other players with their progression.