Compiling C under linux/UNIX
Introduction
Under linux, the C compiler is gcc. It is set as default under several distributions but not on Debian. You should install aptitude install gcc
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 determines 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, however Valgrind is preferred for testing in more depth, 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 masource.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.