Windows OS

How to Install GCC Compiler for Windows

GCC, which stands for GNU Compiler Collection, has become an immensely popular and widely adopted compiler. It was formally introduced in 1987 for the C programming language. Since then, it received many updates. Now it supports C, C++, their objective variants, Fortran, Go, and more.

GCC is considered the best because it allows you to work with numerous less-popular architectures. Moreover, with the GCC compiler, you can also build the Linux kernels and other systems. Although it has a cross-platform support, many users don’t know how to install it in Windows OS. Here, you will get to know about the simple way to install the GCC compiler for Windows.

How to Install the GCC Compiler for Windows

First, download MinGW (Minimalist GNU for Windows) which compiles and executes the codes in the mentioned languages.


Now, locate the downloaded “.exe” file in File Explorer and run it to start the installation process. In the next window, click on the “Install” button.


This installation will proceed in two steps. First, it requires you to specify the installation directory, whether you want a graphical user interface, and a few more options. Set these options according to what suits you best. Then, click on “Continue”.


In the second step, it automatically starts downloading the MinGW Installation Manager.


After it completes downloading, press on “Continue” and it will open the MinGW Installation Manager.


Here, you’ll see a list of packages. To install any of them, click the checkbox for the package. Then, select “mark for installation” from the menu.

As we want to install the GCC compiler, the “mingw32-base” is essential. It provides the basic GCC installation including a C compiler and other components.


Here are the languages that the other packages correspond to:

    • The mingw32-gcc-g++ package for C++ language compiler.
    • The mingw32-gcc-fortran for programs that are written in Fortran.
    • The mingw32-gcc-objc for Objective-C compiler.
    • The mingw32-gcc-ada for Ada programming language.

A yellow arrow will appear on the checkbox when marked for installation.


Now, go to the “Installation” option at the top-left and click on “Apply Changes”.


In the new window, click on “Apply” to start downloading these packages.


Once the download starts, it usually takes a few minutes to download. After the download, a new dialogue box that shows the download log will open. You can close it to proceed to the next step.


 

The system path is critical to system security. It lets you specify the directories that your system must search to run the particular commands. It provides the command prompt/shell/terminal with the search path of those commands so you can execute them directly using the command line.

Therefore, you must add the MinGW-W64 bin directory to your system’s path environment variable to use GCC in the command line. So, follow the given steps for it:

First, copy the path from File Explorer because we’ll set this in the environment variable. If you modified the installation directory in the installation process, copy that path. Otherwise, go to the C drive and locate the folder named “MinGW”.

Open the folder and right-click on the bin and then select “Copy as path”.

To add it to the system path variable, type “edit the system environment variables” and click on “Open”.

In this tab, click on “Environment Variables”. Then, a new tab will appear that displays the currently set variables. Under the “User Variables” tab, select “Path”, and then click on “Edit”.

A new tab with the name “Edit Environment Variables” will open. Since we want to add a new path, click on “New”. It will create an empty entry.

Enter the path that you copied in the first step and press on “OK” to confirm your entry.


With the provided steps, you have successfully installed the GCC compiler in your Windows system.

Conclusion

The GCC compiler is a multi-language compiler that supports all the widely used operating systems such as Windows and Linux. Since its installation is complex, most users cannot install it on their Windows systems. Therefore, this guide explains how to install the GCC compiler in Windows in a simple step-by-step process. This process starts with downloading the MinGW installation manager and ends with integrating the compiler into the system path.

About the author

Prateek Jangid

A passionate Linux user for personal and professional reasons, always exploring what is new in the world of Linux and sharing with my readers.