These days to learn some of the Linux knowledge, your own study notes, recorded here, in order to motivate themselves to progress.
GCC is the best compiler to look at how to compile a simple C program using GCC:
hello.c
#include <stdio.h>int main () {printf ("Hello c!\n");}
To compile this simple program, you only need to execute it under the terminal.
Gcc-o Hello hello.c
In this way, the GCC compiler generates a hello executable file;
To see how the program performs, you only need to execute it under the terminal
./hello
You can see the results of the program output.
Explanation: GCC in the command indicates that the compiler we are using is GCC
-O indicates that the compiler is required to output the executable file, followed by the output executable file name
HELLO.C means our source program.
In fact, the GCC compiler has a number of options, and generally we just need to know how many of them are enough. The-o option we already know, indicates the executable file name we are asking for output. The-c option means that we only require the compiler to output the target code, not the necessary output of the executable file. The-G option indicates that we are asking the compiler to provide us with information for debugging the program at compile time.
In the next section, learn some more about GCC.
Linux Learning C language (1)------source program compilation