GCC is a very important source code compilation tool under the Linux operating system and has many important options to support the compilation of many different languages, such as C, C + +, Ada, Fortran, Objective, Perl, Python, Ruby and Java, etc. Even Linux's many kernels and many other free software and open source applications are written in C and compiled by GCC.
1. Compiling a single source file
[For example] print "Hello,linux." On the screen.
[Source code]
#include <stdio.h>
#include <stdlib.h>
int main (int argc,char **argv)
{
printf ("hello,linux.\n");
Exit (0);
}
Save the source file as hello.c and start compiling
$GCC-O Hello hello.c
After the compilation completes successfully, under the current path, generate a file named Hello, and then execute
$./hello
On the screen, you will see the results of the printing: Hello,linux.
Note: By default, after the compilation completes successfully, a file named A.out is generated under the current path, and then the $./a.out can be printed, but you can usually specify your own executable name by using the option-O.
How to compile and run C programs under Linux