> ## Content Index
> Fetch the complete content index at: https://developerinsider.co/llms.txt
> Use this file to discover other available public pages before exploring further.

# Compile C program with gcc compiler on Bash on Ubuntu on Windows 10 & 11
- URL: https://developerinsider.co/compile-c-program-with-gcc-compiler-on-bash-on-ubuntu-on-windows-10/
- Published: 2016-11-19T11:26:00.000Z
- Updated: 2023-09-04T06:26:45.000Z
- Author: Vineet Choudhary
- Tags: Wiki, Primary, C Programming, C++, C, Compiler, gcc

The GNU Compiler Collection (GCC) is a compiler system produced by the GNU Project supporting various programming languages. You can compile a C program by using the gcc command in Windows 10 Bash on Ubuntu.

## 1.Enable Bash on Ubuntu on Windows 10

If you don't have a enable Ubuntu on Windows check out [Stepwise Guide to Enable Windows 10’s Ubuntu Bash Shell (Windows Subsystem for Linux).](https://developerinsider.co/stepwise-guide-to-enable-windows-10-subsystem-for-linux/)

## 2\. Install gcc compiler in Windows 10 Bash

To install `gcc` compiler in Windows 10 Bash, Open bash and run this command

```sh
apt-get install gcc

```

![](https://github.com/developerinsider/developer-insider-content/blob/master/POST/Tools/GCCRun/installgcc.png?raw=true)

Make sure compiler is installed on your Windows 10 Bash. Type the following command to verify that gcc is installed:

```sh
which gcc

```

**Sample outputs:**

```sh
/usr/bin/gcc

```

Find out version of gcc, run:

```sh
gcc --version

```

![](https://github.com/developerinsider/developer-insider-content/blob/master/POST/Tools/GCCRun/gccversion.png?raw=true)

## 3\. Write your first program on bash

Use a text editor such as nano or vi to create a C program called hello.c:

```sh
nano hello.c

```

![](https://github.com/developerinsider/developer-insider-content/blob/master/POST/Tools/GCCRun/nanohelloc.png?raw=true)

Type the following lines (program):

```c
#include <stdio.h>

int main()
{
  printf("hello world\n");
  return 0;
}

```

![](https://github.com/developerinsider/developer-insider-content/blob/master/POST/Tools/GCCRun/nanowrite.png?raw=true)

After writing your program, press `Ctrl + O` and hit `Enter` key to save your program. To exit nano press `Ctrl + X`.

## 4\. Compile and Run Program

To compile C program `hello.c`, and create an executable file called hello, enter:

```sh
gcc hello.c -o hello

```

To execute program first, enter:

```sh
./hello

```

**Output:**

```
hello world

```

![](https://github.com/developerinsider/developer-insider-content/blob/master/POST/Tools/GCCRun/runcompile.png?raw=true)