DEV Community

Cover image for How to install gcc in Windows 10? (the easier way)
Sudev Suresh Sreedevi
Sudev Suresh Sreedevi

Posted on • Updated on

GCC for Windows How to install gcc in Windows 10? (the easier way)

GCC, abbreviation for 'GNU Compiler Collection' (thanks @saphirakai) (and not Gulf Cooperation Council, like I'd assumed) is a necessity if you (or your pesky college) is into C Programming.

Almost all Linux distros come pre-installed with it so they are out of the trouble. But for those of you who were constant users of Windows and Command Prompt, and never felt the necessity for a C compiler, GCC seems to come out of the blue and a tough nut to install. 1000 rage-quits later, I present you this article.

This article is written so that the installation process is made easier than most of the trashy articles I had to go through.

Installation

  1. Go to MinGW official website and click on 'Downloads' on the left panel. You'll be redirected to the site which hosts the files. Important Edit: MinGW official website is now down (as of 24th March 2021). Hence, instead of their official website, download from MinGW SourceForge page
  2. Look for mingw-get-setup.exe for downloading. Download it and launch the installer. Accept the terms and move on.
  3. You'll now see that the installer is connecting to the Internet and downloading a lot of tiny and small files. Wait till it ends.
  4. Right when it ends (which won't take long), you'll be presented a window with title MinGW Installation Manager. You should be in the 'Basic Setup' tab by default when it launches. If not, click on Basic Setup.
  5. Out of the numerous check boxes presented to you on the right side, tick "mingw32-gcc-g++-bin". If you are prompted with a menu, click on Mark for Install.
  6. Then on the top left corner click on Installation > Apply Changes. And wait while it downloads a billion files and installs them.

MinGW Installation Manager

  1. Now you gotta edit your "Environment Variables" as well, so that gcc works in cmd no matter the file location.
  2. For that go to Windows Explorer > Right click on This PC > Properties > Advanced system settings > Environment Variables or you could just search for "Environment Variables" in Windows Search...
  3. At the bottom "System Variables" panel, look for a Variable named "Path" and double click on it. Some systems show a good UI for adding a New Path easily (by clicking New), else you just need to add ; at the end and add the following path

    
    
    C:\MinGW\bin
    
    ###### (This is assuming you didn't manually change any installation paths and went with just clicking 'Next' during installation)

10. Click on OK, and OK and close the other windows. Open a Command Prompt Terminal and try typing `gcc --version` and press Enter.

    If you get something like
    ```


    gcc (MinGW.org GCC Build-2) 9.2.0
    Copyright (C) 2019 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.


Enter fullscreen mode Exit fullscreen mode
gcc has been successfully installed in your PC. Enjoy!
Enter fullscreen mode Exit fullscreen mode

Cheers and happy coding!

Top comments (35)

Collapse
 
darthnithin profile image
Nithin

or just do choco install mingw

Collapse
 
artemiikravchuk profile image
Artemii Kravchuk

Thanks, that just saved me a lot of time lol!!!!
I didn't know it was possible, nobody writes about it...

Collapse
 
williycole profile image
William Cole Boren • Edited

self #smh #facepalm

Image description

Collapse
 
devchaudhary78 profile image
Dev Chaudhary

Amazing (:

Collapse
 
saphirakai profile image
Saphira Kai

GCC is not an acronym for GNU C Compiler, that's a misconception. It stands for GNU Compiler Collection, as GCC has support for many languages; including C++, Objective-C, Objective-C++, Fortran, Ada, D, and Go, not just C.

Collapse
 
devchaudhary78 profile image
Dev Chaudhary

Good Catch buddy (:

Collapse
 
raddevus profile image
raddevus

Thanks for sharing this article. It has great info. After reading this I also found a great article on using Visual Studio Code on Win10 and mingw -- code.visualstudio.com/docs/languag.... It includes links directly to the installation of MinGW so that is helpful too.

Collapse
 
jbrown123 profile image
James Brown

The mingw.org site is down (as noted above). However, the older SourceForge site has a stale copy. The new site is osdn.net/projects/mingw/

OP, please update the link above in the article to the new site.

Collapse
 
micro-pc-tech-inc profile image
Micro Pc Tech Inc

To install the GNU Compiler Collection (GCC) on Windows 10, you can use the MSYS2 environment, which provides a Unix-like shell and a package management system for Windows. Here's a step-by-step guide:

Install MSYS2:

Download the MSYS2 installer from the official website.
Run the installer and follow the on-screen instructions.
When prompted, choose the installation directory (the default is usually fine).
Update MSYS2:

Open the MSYS2 Shell that was installed with the MSYS2 package.

Run the following commands to update the package database and core system packages:
pacman -S mingw-w64-x86_64-toolchain
This may take some time as it updates the system.

Install GCC:

After the update, install the GCC package using the following command:
pacman -S mingw-w64-x86_64-toolchain
This will install the GCC compiler and related tools.

Add GCC to the System Path:

Once the installation is complete, you need to add the GCC binaries to the system path so that you can run them from any command prompt.

Locate the installation directory (default is C:\msys64).

Add the bin directory to the system path. You can do this by adding the following line to your system or user environment variables:
C:\msys64\mingw64\bin
Make sure to adjust the path if you installed MSYS2 in a different directory.

Verify Installation:

Open a new command prompt and type the following command to verify that GCC is installed:

bash
Copy code
gcc --version
You should see information about the GCC version.

That's it! You have successfully installed GCC on Windows 10 using MSYS2. You can now use GCC to compile C and C++ programs from the command line.

Collapse
 
sieler profile image
Stan Sieler

Hi...your (revised) article worked to perfection, thanks! (Installed gcc on 2021-05-03 on Win 10).

For me, gcc is only 80% of the bits I need ...

I also need: make

and: /usr/include/* (e.g., , )

I know I've found/installed them three or four times over the last 20+ years,
but each time it's a new challenge (hmmm...maybe better note keeping?)

thanks!
Stan

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt
Collapse
 
tingwei628 profile image
Tingwei

THANK YOU!

Collapse
 
sahin52 profile image
sahin52

You are perfect

Collapse
 
amdev1392 profile image
Arsalan Mohseni

How do i install pacman on it??

Collapse
 
bharadwn profile image
Nandita

thank you