GCC (GNU Compiler Collection) is the most commonly used C language compiler under Linux and is a compiled system conforming to the ANSI C standard in the GNU project, capable of compiling programs written in C, C + +, and object C.
There are two common ways to use Linux systems, as follows:
Gcc-o out in1 in2 //gcc Compile and link (compile and build in2 file for in1 and Out.bin files, "-O": Represents the build executable file)-C out in1 in2 // GCC compilation is not linked (in1 files and in2 file files are compiled to generate OUT.O files, "-C": Indicates that only *.O files are generated)
In the ARM Development Board, you need to use ARM-LINUX-GCC cross-compiling:
Arm-linux-gcc-o out in1 in2 //gcc Compile and link (compile and build in2 file for in1 and Out.bin files, "-O" : Represents the build executable file)arm-linux-gcc-c out in1 in2 // GCC compilation is not linked (in1 files and in2 file files are compiled to generate OUT.O files, "-C": Indicates that only *.O files are generated)
To compile two programs A.C and hello.c as an example:
VI a.c //Edit A.C, it will be called by HELLO.C, provided that the two files must be in the same directory
The contents are as follows:
VI hello.c //Edit hello.c
The contents are as follows:
gcc-o Hello hello.c a.c //gcc compile and link (compile the hello.c file and a.c file to generate Hello.bin file, "-O": Represents the build executable file)
./hello //Run Hello.bin
The effect is as follows:
Using GCC to compile and run C programs under Linux