Compiling C under linux/UNIX

October 2016


Under linux, the C compiler is gcc. It is set as default under several distributions but not on Debian. You should install it:aptitude install gcc


Gcc is the acronym for GNU compiler collection created by the GNU project. This is a collection of integrated software capable of compiling various programming languages including C, C + +, Objective-C, Java, Ada and Fortran. It is used for the enhancement of all freeware. Linux OS depend directly of the GCC function.

The abbreviation GCC is used for three different entities:
  • 1. The complete collection of compilers;
  • 2. Part common to all compilers;
  • 3. the C compiler itself.

To refer specifically to the compilers of each language, it refers as:
  • GCC for C
  • G++ for C++
  • GCJ for Java
  • GNAT for Ada
  • Gfortran for Fortran
  • GPC for Pascal
  • GHDL for VHDL

GCC also has a tool for debugging, GNU Debugger (gdb). Although not part of GCC, Valgrind is preferred for more in depth testing, particularly to search for memory leaks.

GNU Debugger (gdb) is the debugging tool for GNU. However despite that Valgrind is not compiled with GCC, it is the most commonly used for serious troubleshoot.

Syntax GCC

Below are the two main commands of gcc for c :
  • $ gcc mysource.c # ==> creates executable a.out to be launched with../a.out.
  • $ Gcc-o-<name_of_program> c <mysource>. c # ==> The argument o-enables you to choose the name of the executable that will emerge from this compilation.

Related :

This document entitled « Compiling C under linux/UNIX » from CCM ( is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.