You need to:
- Update and upgrade:
$ sudo apt-get update && sudo apt-get upgrade -y

2.Clean unrequired packages:
$ sudo apt autoremove -y

- Install GCC:
$ sudo apt-get install gcc -y

- Check and confirmed installed gcc version:
gcc --version

You need to:
- Update and upgrade:
$ sudo apt-get update && sudo apt-get upgrade -y

2.Clean unrequired packages:
$ sudo apt autoremove -y

- Install GCC:
$ sudo apt-get install gcc -y

- Check and confirmed installed gcc version:
gcc --version

I too was trying to install gcc for my WSL.
I first tried the "sudo apt-get install gcc" to begin with (after coming here).
But then after entering "gcc --version", the terminal spat out:
Command 'gcc' not found, but can be installed with:
sudo apt install gcc
I then just tried just "sudo apt install gcc" like the terminal had suggested.
Then after again entering "gcc --version", the terminal spat out:
gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.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.
Suggesting that it worked.
Videos
I want to know, is there a difference between the GCC compiler on Linux and on Windows. At my faculty they tell us to use a Linux virtual machine to run our programs. I find this slow. I, instead, use WSL2. Is there a difference between using that and a Linux VM, and is there a difference between just using Windows and using Linux.
Why compiling? You should be able to install the package:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install g++-7 -y
Verify using:
gcc-7 --version
See How to install gcc-7 or clang 4.0?
run the following
sudo apt install aptitude
sudo aptitude install gcc-7 g++-7
or
sudo apt install aptitude && sudo aptitude install golang gcc-7 g++-7
You need to install glibc or other libc implementation. I recommend installing the build-essential package.
sudo apt upgrade
sudo apt install build-essential
The build-essential package is designed to include software necessary to build Debian packages, which probably isn't what you need -- but includes all the packages necessary to build C code, including gcc and glibc.
Minimally, you can install the libc6-dev package.
Okay, here is what I did.
I got rid of all my gcc stuff (probably not nessessary):
sudo apt remove gcc
I made a backup of my /etc/apt/sources.list:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
Found a mirror site to get my gcc files by going to https://help.ubuntu.com/community/Repositories/CommandLine Followed the link "official mirror list" on that page Found a mirror for the United States (I used Pilot Fiber)
Grabbed the URL from the mirror site https://mirror.pilotfiber.com/ubuntu/
Edited my sources.list to include the mirror site
sudo nano /etc/apt/sources.list
then commented out top repository and added the mirror-site repository
[COMMENTED OUT -->] #deb http://archive.ubuntu.com/ubuntu/ jammy main
restricted[ADDED -->] deb https://mirror.pilotfiber.com/ubuntu/ jammy main
FYI, jammy is the codename for my Ubuntu distribution (you can find yours via the command line with lsb_release -a)
Updated my apt source list
sudo apt update
Used apt to install "build-essential" which includes the gcc compiler
sudo apt install build-essential
Checked for gcc
gcc -version
output: gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 ...
Successfully compiled and ran some test programs
I've only begun using Bash on Ubuntu and recently attempted to install gcc. When I try to run gcc I get informed I must install gcc. Although I did notice during the installation there were some errors ?
I tried to install gcc in Ubuntu on WSL2 and get the following error,
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/l/linux/linux-libc-dev_5.4.0-54.60_amd64.deb 404 Not Found [IP: 91.189.88.152 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
Please help me fix this.