Installing GCC Compiler in Windows To Run C Program on Gitbash and Setting the PATH Variable
Installing GCC to run C program

Installing GCC Compiler in Windows To Run C Program on Gitbash and Setting the PATH Variable

GCC, or GNU Compiler Collection, is a popular open-source compiler used for developing and executing various programming languages, including C, C++, Fortran, Ada, and more. In this article, we will guide you through the process of installing GCC on a Windows operating system and setting the PATH variable.

Step 1: Download MinGW-w64

The first step in installing GCC on Windows is to download MinGW-w64, a compiler that provides support for GCC on Windows. You can download MinGW-w64 from?Here.

Step 2: Install MinGW-w64

Once the download is complete, double-click on the MinGW-w64 installer file to start the installation process. The installer will guide you through the installation process and prompt you to select the components you wish to install.

Step 3: Select Packages Required for the Compiler.

There are three packages required for the basic MinGW setup that you have to choose from the MinGW Installation Manager.

  1. MinGW32-base Package.
  2. First, you have to install the?MinGW32-base package. This package is used to compile the C program, including linker and other binary tools. Right-click on the MinGW32-base option and select Mark for Installation.
  3. MinGW32-gcc-g++ Package.
  4. Now you have to install the MinGW32-gcc-g++ package. This package is used to compile C++ source code. This is an optional component of the MinGW Compiler. It is only required if you are going to program in C++ language only. To select the MinGW32-gcc-g++ right-click on it and select Mark for Installation.
  5. MinGW32-gcc-objc package.
  6. At last, you have to install the MinGW32-gcc-objc package. This package is used to compile objective C language. It is an optional component. It is only required if you are going to program in objective C. To select the MinGW32-gcc-objc package, right-click on it and select?Mark for Installation.

Step 4: Apply the Changes

After selecting all the required packages, go to Installation>>Apply Changes and click on Apply Changes.

Step 5: Download the Changes.

Now it is time to download all the packages you selected in the previous step. Click on Apply and proceed further to download and install them.

This process might take a while, you just be patient. After the installation of MinGW is finished. To check if it is installed or not, open Command Prompt and type g++ — version.

The MinGW compiler (GCC) is not being detected by the command prompt because the environment path variable has not been set. The environment path variable is crucial in detecting the compiler throughout the system and creates an alias name for the compiler, indicating its location. To set the environment path variable for MinGW on a Windows system, follow the steps outlined below.

Setting up Path Variable

To set up the path for the C compiler for windows, follows the below steps :

Step 1: Copy the path of the MinGW bin.

When you install the MinGW, it creates a folder named MinGW in C: Drive. To set the compiler’s path, we need the path to the bin directory of MinGW. So, first,

  • Go to C:>MinGW>bin.
  • Now, inside the bin folder, click on the address bar and copy the address.
  • We require this address to be set as the path in the environment variable.
  • If your install location was somewhere else, you may go to that location where you have installed MinGW.

Step 2: Setting the Environment Variable

  1. Open the Start menu and type “Environment Variables” in the search bar.
  2. Click on “Edit the system environment variables” and then click on “Environment Variables”.
  3. In the Environment Variables window, scroll down to the “System Variables” section and find the “Path” variable.
  4. Click on the “Edit” button next to the “Path” variable.
  5. In the Edit Environment Variable window, click on “New” and then paste the path you copied earlier from your bin.
  6. Click “OK” to save the changes.

Step 3: Verify the Installation

To verify the installation of GCC on your Windows system, open the Command Prompt and type the following command:

gcc — version

If the installation was successful, you should see the version of GCC that you have installed.

Conclusion

Installing GCC on Windows and setting the PATH variable is a straightforward process. With GCC installed, you can now start developing and compiling programs in various programming languages. Remember to always double-check the PATH variable to ensure that the system can locate the GCC compiler.

<p> Never miss out on resources, opportunities to help you grow as a tech enthusiast. </p>

<a href=’#’>I regularly post them here

Twitter

LinkedIn

Find me on?GitHub

</a>

If you love such materials, please follow to see more contents.

<code on>

#Gitbash #GCC #Compilers #C #C++

Hoseyn A. Amiri

Mechanical Engineer specializing in Microfluidics

1 年

How can you turn .c file into dll using gcc?

回复
Mantraay Patil

3rd Year - Electronics and Computer Science Student at University of Edinburgh

1 年

Very clear and very helpful. Thank you so much for walking me through this.

回复
Idowu Joshua Ade'simon

Web3 | Sales Manager | Land and Properties |

1 年

not able to add to the system variable as it didn't highlight the 'edit' button for use.

回复

要查看或添加评论,请登录

David Michael的更多文章

  • Django REST Framework Sign-up/Sign-in With Social Accounts

    Django REST Framework Sign-up/Sign-in With Social Accounts

    While developing an API with Django Rest Framework (DRF), I was faced with the challenge of implementing Social…

    10 条评论
  • Technology: The Field of the Future

    Technology: The Field of the Future

    Technology is one of the most rapidly growing and dynamic fields today, and there are many reasons why choosing a…

    1 条评论

社区洞察

其他会员也浏览了