Compile C program with gcc compiler in Windows 10



Compile C program with GCC compiler

The GNU Compiler Collection (GCC) is a compiler system produced by the GNU Project supporting various programming languages. You can compile by using the GCC command in Windows 10 Bash on Ubuntu. GCC is a key component of the GNU toolchain and the standard compiler most Unix-like operating system. 

       C Programming Tutorials for Beginners

       Downloading Programming E-BOOK

Compile C program on windows 10


1. Enable Bash on Windows 10

If you don't know how to Enable/Activate Bash on Ubuntu on Windows 10, then check out our this tutorial Learn Stepwise to Enable Win 10 Subsystem for Windows 10.






2. Install gcc compiler in Windows 10 Bash

Enter the following command in your bash terminal to Install GCC compiler in Windows 10 Bash. Installation Guide for Windows.

                                         apt-get   install gcc           

Windows 10 Bash


After successfully the compiler is installed on your Windows 10 Bash. Type the following command to verify that gcc is installed: 
                                         which gcc

Example Outputs: 

                                        /usr/bin/gcc

How to find out the version of GCC compiler


                                       gcc   --version

Install gcc compiler in Windows  Bash




3. Write your first program on bash

Use any type of TEXT EDITORS such as vim or nano to create a C program called hello.c:

                             vim hello.c   or   nano hello.c

how write program on bash


Type your lines of  programming in command screen (example):




write program lines in text editor app

After writing your program, press ctrl+o and click on  Enter key to save your program. To quiet press Ctrl + x.





4. How Compile & Run Program

Compile hello.c  C program, and create a .exe (executable) file called hello, enter:

                                           gcc   hello.c   -o   hello       

To execute program first, enter: 


                                                         ./hello

 Output:


                                       hello world

gcc compiler Windows 10

Post a Comment

1 Comments

Ask Me Everything About Programming.