How To Install gcc-riscv64-unknown-elf on Ubuntu 22.04

In this tutorial we learn how to install gcc-riscv64-unknown-elf on Ubuntu 22.04. gcc-riscv64-unknown-elf is GCC compiler for embedded RISC-V chips

Introduction

In this tutorial we learn how to install gcc-riscv64-unknown-elf on Ubuntu 22.04.

What is gcc-riscv64-unknown-elf

gcc-riscv64-unknown-elf is:

Bare metal compiler for embedded RISC-V chips supporting both 64 and 32 bit architectures. This package includes patches for vendor-specific ISA extensions.

There are three methods to install gcc-riscv64-unknown-elf on Ubuntu 22.04. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install gcc-riscv64-unknown-elf Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install gcc-riscv64-unknown-elf using apt-get by running the following command:

sudo apt-get -y install gcc-riscv64-unknown-elf

Install gcc-riscv64-unknown-elf Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install gcc-riscv64-unknown-elf using apt by running the following command:

sudo apt -y install gcc-riscv64-unknown-elf

Install gcc-riscv64-unknown-elf Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install gcc-riscv64-unknown-elf using aptitude by running the following command:

sudo aptitude -y install gcc-riscv64-unknown-elf

How To Uninstall gcc-riscv64-unknown-elf on Ubuntu 22.04

To uninstall only the gcc-riscv64-unknown-elf package we can use the following command:

sudo apt-get remove gcc-riscv64-unknown-elf

Uninstall gcc-riscv64-unknown-elf And Its Dependencies

To uninstall gcc-riscv64-unknown-elf and its dependencies that are no longer needed by Ubuntu 22.04, we can use the command below:

sudo apt-get -y autoremove gcc-riscv64-unknown-elf

Remove gcc-riscv64-unknown-elf Configurations and Data

To remove gcc-riscv64-unknown-elf configuration and data from Ubuntu 22.04 we can use the following command:

sudo apt-get -y purge gcc-riscv64-unknown-elf

Remove gcc-riscv64-unknown-elf configuration, data, and all of its dependencies

We can use the following command to remove gcc-riscv64-unknown-elf configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge gcc-riscv64-unknown-elf

References

Summary

In this tutorial we learn how to install gcc-riscv64-unknown-elf package on Ubuntu 22.04 using different package management tools: apt, apt-get and aptitude.