How to compile a “C” program using GCC

Mohamed Foued Jenni
2 min readSep 18, 2020

--

GCC icon

What’s GCC :

GCC is a short for GNU Compiler Collections which is used to compile C and C++ language programs for Linux.

It can also be used to compile Objective C and Objective C++.

Syntax :

gcc [-c|-S|-E] [-std=standard]

Note : you can type “man gcc” on your terminal for more information about the command.

Example :

This will compile the “main.c” file and give the output file as “a.out” file which is default name of output file given by gcc compiler, which can be executed using ./a.out .

1- We used the command “ls” to list all files and directories in the current directory and as you can see we already have the file main.c

You can check my article about the ls command in the link below :

2-We used our powerful command gcc main.c to get an executable file called “a.out” .

3-We used ls again to show you the our new file “a.out”.

4-And finally we executed the file a.out using “./a.out” which gives us “Hello World” as an output message .

I hope that this article explained to you how to use gcc thank you for reading and see you inthe next article .

--

--