GCC, abbreviation for 'GNU C Compiler' (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
-
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 - Look for mingw-get-setup.exe for downloading. Download it and launch the installer. Accept the terms and move on.
- 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.
- 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.
- 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.
- Then on the top left corner click on Installation > Apply Changes. And wait while it downloads a billion files and installs them.
- Now you gotta edit your "Environment Variables" as well, so that gcc works in cmd no matter the file location.
- 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...
-
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)
-
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.
gcc has been successfully installed in your PC. Enjoy!
Cheers and happy coding!
Discussion (8)
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.
I got an error for compiling CGO. Fixed with TDM.
THANK YOU!
Please suggest as mingw site is not working
try mingw-w64.org/doku.php. Seems that the mingw site's domain has expired.
I created an account just to thank you for saving me the headache.
Thank you very much.
You are perfect