DEV Community

IamSh
IamSh

Posted on

Gcc on windows install

If you have Homebrew installed on your Windows machine (via WSL - Windows Subsystem for Linux), you can use it to install GCC. Here's how:

Install Homebrew on Windows (WSL):

  1. Install WSL:

    • Make sure you have WSL enabled on your Windows machine. You can do this through "Turn Windows features on or off" in the Control Panel.
    • You can follow Microsoft's guide to install WSL.
  2. Install Ubuntu (or another Linux distribution):

    • Once WSL is installed, you need to install a Linux distribution from the Microsoft Store. Ubuntu is a popular choice:
      • Open Microsoft Store and search for "Ubuntu".
      • Click on "Ubuntu" and then click "Install".
  3. Set Up Ubuntu:

    • Launch Ubuntu from the Start menu or the command line.
    • Follow the on-screen instructions to set up a new Linux user account and password.

Install GCC with Homebrew:

Now that you have WSL and Ubuntu installed, you can use Homebrew to install GCC:

  1. Update Ubuntu:

    • In the Ubuntu terminal, run:
     sudo apt-get update
    
  2. Install Homebrew:

    • Run the following commands in the Ubuntu terminal:
     sudo apt-get install build-essential curl file git
     /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
  3. Install GCC:

    • After Homebrew is installed, use it to install GCC:
     brew install gcc
    
  4. Verify Installation:

    • After installation is complete, you can verify GCC is installed by running:
     gcc --version
    

Using Homebrew for Windows (Alternative):

If you have Homebrew for Windows (which installs packages in the Windows environment, not WSL), you can also use it to install GCC:

  1. Install Homebrew for Windows:

    • Visit brew.sh and follow the installation instructions to install Homebrew on Windows.
  2. Install GCC:

    • Open Command Prompt or PowerShell as Administrator.
    • Run the following command to install GCC:
     brew install gcc
    
  3. Verify Installation:

    • After installation is complete, you can verify GCC is installed by running:
     gcc --version
    

Homebrew for Windows works similarly to the macOS version, but it's important to note that it's a separate project from the Linux-focused Homebrew, so the available packages might differ.

Top comments (0)