Install gcc 13 on Ubuntu 22.04

Install gcc 13 on Ubuntu 22.04

The gcc is a compiler of the GNU Compiler Collection (GCC). The gcc compiler is mainly used to compile C programs.

This tutorial demonstrates how to install gcc 13 on Ubuntu 22.04.

Install gcc

Run the following command to add the Toolchain repository:

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

Install gcc 13:

sudo apt install -y gcc-13

Check gcc version to verify that the installation completed successfully:

gcc-13 --version

Testing gcc

Create a main.c file:

nano main.c

Add the following code:

#include <stdio.h>

int main() {
    printf("Hello world\n");

    return 0;
}

Compile a code:

gcc-13 main.c -o test

Run a program:

./test

Uninstall gcc

If you want to completely remove gcc and related dependencies, run the following command:

sudo apt purge --autoremove -y gcc-13

Remove GPG key and repository:

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-jammy.list

The 1 Comment Found

Leave a Comment

Cancel reply

Your email address will not be published.