January 18, 2025

Installing C Compiler on Windows OS

If you want to compile the C application, you need to install C compiler. There are many open source C compilers are available. We will use the open source compiler: GNU C/C++ compiler. For this, you need to install MinGW. Go to the official website: http://mingw-w64.org/doku.php

Click on the link which is highlighted in red mark.

Click on Files. Then in the next page, you will see the link to download the exe as shown below.

Click on this exe. It will download the exe file to your system.

Double click this exe and then click Next.

In the Version, Architecture and for other fields it will have default values. No need to change any values for these fields.

In my system, this software is installed in the location: C:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0
Click Next

For me it took around 10 min. to install the software. So, wait for few minutes.

Once the software installed successfully, go to the location where this is installed. In my case C:\Program Files (x86)\mingw-w64
Click the folder: i686-8.1.0-posix-dwarf-rt_v6-rev0 then go to mingw32\bin

Here you can see the exe files. We need to set this path in the environment variable. Copy the bin location: C:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin
Note: In your case, location might be different. So, select the proper location.

Go to My Computer. Select This PC as highlighted below. Right click on this, click on Properties

You will see the Advanced system settings. Click on this.

Now click on Environment Variables

Under the System variables, click on Path as highlighted below. Click on Edit Button.

This will display list of paths that is already added to the Path. Now, click on New

Add the C compilers bin location as mentioned below: C:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin Click on OK.

Now, open command prompt. Type gcc –version
You should see the compiler version. If yes, congrats ! You have installed C compiler successfully.

Now write below code in notepad.save the file as hello.c (.c is the extension)

#include <stdio.h>
 
int main()
{
    printf("Hello, World!");
    return 0;
}


I have saved the file in the location c:\tutorial

Now, open command prompt. Go to the location where you have saved the file by using the command
cd c:/tutorial
To compile the C program, use the command: gcc hello.c
This command will compile the C program and if there are no issues, then compiler will create the exe file.
In this case, file name will be a

Executable file: a.exe has been created. Please check your folder location.

Will execute this file by using the command a

If you file executed and displays the output: Hello, World!

Do not want to install any software. Still can i write C programming?
If you do not want to install C compiler, But still wanted to explore C programming, then you can use the online C compiler. Many websites provides utility to write C Program on their platforms. Try google: Online C program You will get lot of websites, there you can try C programming.

Leave a Reply

Your email address will not be published. Required fields are marked *