How to install gcc on Linux?

There are several different methods to install GCC on Linux, you can choose any one of them for installation.

  1. Install using package manager.
  2. For Ubuntu or Debian: Open the terminal and run the command ‘sudo apt-get install gcc’.
  3. For CentOS or Fedora, open the terminal and run the command sudo dnf install gcc or sudo yum install gcc.
  4. To install gcc on Arch Linux, open the terminal and execute the command sudo pacman -S gcc.
  5. Install from source code:
  6. Firstly, download the latest version of the GCC source code package from the official GCC website (https://gcc.gnu.org/releases.html).
  7. In the terminal, use the tar command to extract the downloaded source code package. For example, run tar -xf gcc-X.X.X.tar.gz, where X.X.X is the version number of GCC you downloaded.
  8. Navigate to the extracted directory and execute the following commands: ./configure
    make
    sudo make install.
  9. Use containers:
  10. If you have experience with Docker or other container technologies, you can use an image that already includes GCC. In Docker, you can run the following commands to get an Ubuntu image with GCC included:
    docker pull ubuntu
    docker run -it ubuntu
    apt-get update
    apt-get install gcc

    This will download and install GCC in a new Ubuntu container.

After installation, you can enter ‘gcc –version’ in the terminal to verify if GCC has been successfully installed and display the installed version number.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds