You need to:

  1. Update and upgrade:
$ sudo apt-get update && sudo apt-get upgrade -y

2.Clean unrequired packages:

$ sudo apt autoremove -y

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

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

Answer from Hasan A Yousef on Stack Overflow
🌐
Solarian Programmer
solarianprogrammer.com › 2017 › 05 › 04 › building-gcc-wsl-windows-subsystem-linux
Building GCC 10 on Windows Subsystem for Linux | Solarian Programmer
Let’s make sure that you have an up to date system, start WSL and write: ... 1 cd ~ 2 wget https://ftpmirror.gnu.org/gcc/gcc-10.1.0/gcc-10.1.0.tar.xz 3 tar xf gcc-10.1.0.tar.xz 4 cd gcc-10.1.0 5 contrib/download_prerequisites · At this point, we can configure the build. In order to keep the system clean, we will use /usr/local/gcc-10.1.0 for the installation folder and append the suffix -10.1 to the GCC compilers.
🌐
Host IT Smart
hostitsmart.com › manage › knowledgebase › 435 › install-gcc-compiler-on-windows.html
How to Install GCC Compiler on Windows?
May 21, 2025 - If you prefer a Linux-like environment on Windows, the best way to install GCC is through Windows Subsystem for Linux (WSL).
🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 1479805 › how-to-access-gcc-installed-on-windows-in-wsl
HOW to ACCESS GCC installed on windows in wsl - Microsoft Q&A
It's supported to run Windows executables from WSL and the Windows file systems are mounted under /mnt. Sorry I do not use msys2 but you can see if the gcc.exe can run normally from bash.
🌐
Wordpress
christophep.wordpress.com › 2018 › 11 › 10 › installing-wsl-ubuntu-bash-gcc-g-on-windows-10
Installing WSL, Ubuntu Bash, GCC, G++ on Windows 10 | ChristopheP on Microsoft Technologies
November 10, 2018 - Go to aka.ms/wslstore and install Ubuntu. Run bash and create a user account with a password. Make a “sudo apt update” to update the repo packages. Then you can do “sudo apt install gcc” and “sudo apt install g++”.
Find elsewhere
🌐
Eleven Forum
elevenforum.com › windows support forums › virtualization and wsl
gcc-11 for Ubuntu 24.04.6 on WSL2 | Windows 11 Forum
June 30, 2023 - sudo apt update && sudo apt upgrade sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa -y sudo apt install -y gcc-11 gcc-11 --version · Click to expand... change the toolchain-r/ppa to toolchain-r/test This worked in a Native ubuntu install --should also work AFAIK on WSL.
🌐
Microsoft Learn
learn.microsoft.com › en-us › cpp › build › walkthrough-build-debug-wsl2
Walkthrough: Build and Debug C++ with Microsoft Windows Subsystem for Linux 2 (WSL 2) and Visual Studio 2022 | Microsoft Learn
Assuming your distro uses apt (this walkthrough uses Ubuntu), use the following commands to install the required build tools on your WSL 2 distro: sudo apt update sudo apt install cmake g++ gdb make ninja-build rsync zip ...
Top answer
1 of 2
2

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.

2 of 2
1

Okay, here is what I did.

  1. I got rid of all my gcc stuff (probably not nessessary):

    sudo apt remove gcc

  2. I made a backup of my /etc/apt/sources.list:

    sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup

  3. 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)

  4. Grabbed the URL from the mirror site https://mirror.pilotfiber.com/ubuntu/

  5. 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)

  6. Updated my apt source list

    sudo apt update

  7. Used apt to install "build-essential" which includes the gcc compiler

    sudo apt install build-essential

  8. Checked for gcc

    gcc -version

    output: gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 ...

  9. Successfully compiled and ran some test programs

🌐
PhoenixNAP
phoenixnap.com › home › kb › devops and development › how to install gcc on windows
How to Install GCC on Windows
September 23, 2024 - Run wsl --list --online to see a list of other available distros, and install one using the syntax below: ... 3. Restart the system when prompted and the installation continues automatically. Type in the username and password you want to use for your Linux distro: After the installation process completes, you can install GCC:
🌐
Up
www3.dcc.fc.up.pt › ~fds › aulas › pi › 2425 › praticas › aula01-configuracao_wsl.html
Brief Tutorial on Configuring WSL and Installing GCC on Windows
Run the following command to install WSL and set Ubuntu as the default distribution: ... After installation, restart your computer if necessary. Once restarted, open Ubuntu (available in the start menu) and follow the on-screen instructions to create a user and password. ... GCC (GNU Compiler ...
🌐
IBM
ibm.com › docs › en › drfz › 9.1.0
IBM Decision Runtime for z/OS
Windows Subsystem for Linux, with GNU Compiler Collection support, is required to use the COBOL support in the Rule Designer.
🌐
Visual Studio Code
code.visualstudio.com › docs › cpp › config-wsl
Using C++ and WSL in VS Code
November 3, 2021 - In this tutorial, you will configure Visual Studio Code to use the GCC C++ compiler (g++) and GDB debugger on Ubuntu in the Windows Subsystem for Linux (WSL). GCC stands for GNU Compiler Collection; GDB is the GNU debugger.
🌐
Reddit
reddit.com › r/bashonubuntuonwindows › installing gcc error
r/bashonubuntuonwindows on Reddit: Installing gcc error
March 20, 2021 -

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.

🌐
GitHub
gist.github.com › Ayush-Kadali › 637c2dac5ca784bc77022329cd434b6c
Install VSCode and gcc using wsl on Windows 10/11 from ground up · GitHub
Type wsl --install in the terminal - Wait for Ubuntu to get installed - Enter your preffered username - Enter your pasword and retype the password · NOTE: WHEN YOU TYPE THE PASSWORD YOU WILL NOT SEE THE CURSOR MOVE SO BE SURE OF WHAT YOU WOULD ...
🌐
GitHub
github.com › microsoft › WSL › issues › 2591
Unable to install gcc dev tools · Issue #2591 · microsoft/WSL
February 10, 2017 - Your Windows build number: 10.0.16299.19 (was also a problem on Creators Update) What you're doing and what's happening: Initially, tried install gcc using: # apt-get install gcc Then ran: dpkg -i /var/cache/apt/archives/linux-libc-dev_4.4....
Published   Oct 23, 2017
🌐
GitHub
gist.github.com › Roy-Fokker › 945c8f4684a3d1ca581cc9d809cdd9bb
Steps to configure WSL ubuntu (latest) with Latest GCC and Clang compilers · GitHub
Steps assume a clean WSL linux distro · sudo apt install build-essential git 7zip zip unzip pkg-config ... sudo update-alternatives \ --install /usr/bin/gcc gcc /usr/bin/gcc-13 13 \ --slave /usr/bin/g++ g++ /usr/bin/g++-13 \ --slave /usr/bin/gcov ...