Embedded operating systems are based on GCC for source code compilation

1.GCC related introduction

What is the difference between GCC and gcc?

● GCC (GNU Compiler Collection)

GNU compiler collection, compilers for many languages: C, C++, Java, D, Objective-C, etc

● gcc: specifically refers to the C compiler in GCC

GCC VS embedded

● Most embedded operating systems are based on GCC for source code compilation.

Linux, VxWorks, Android, etc

●Application in actual development

Kernel development: gcc

Application development: gcc / g++ / gdc

2 first known compiler

The process of gcc compiling code into an executable program completes four steps of preprocessing, compilation, assembly, and linking.

The compiler consists of a preprocessor (cpp tool, C Preprocessor), a compiler (cc tool, C and C++ compiler), an assembler (as tool, assembler), and a connector (ld tool).

3 gcc key compilation options

3.1 Preprocessing instructions

3.1.1 Instruction format

Gcc -E file.c -o file.i

3.1.2 Preprocessing file related content

From the file.i file we can see that there are a large number of lines starting with "#". The format of each line is "# line number file name flag", where "line number" and "file name" indicate which line of the file from which the content starting from the next line comes from; the flag can be 1, 2, 3 And 4 four numbers, the meaning of each number is as follows:

When file.c uses non-system header files and they are not in the current directory, they need to be specified by using gcc's -I parameter, otherwise gcc will report an error because it cannot obtain the necessary header files for macro expansion.

3.2 Compilation instructions

3.2.1 Instruction format

Gcc -S file.i -o file.s gcc -S -O2 file.c -o file.s

3.2.2 Description

When using the -S parameter, we can use the -O option as needed.

3.3 assembly instructions

3.3.1 Instruction format

Gcc -c file.s -o file.o

3.4 Generating a mapping file

3.4.1 Instruction format

Gcc -Wl,-Map=file.map file.c

3.4.2 Description

The mapping file is generated by the ld linker. We can use the mapping file to understand the layout information of each symbol in memory in a program file. Gcc's -Wl option is used to specify the options passed to the linker. The -Map=file.map option is passed by gcc to the linker to instruct the linker to generate a map file named file.map for us. When using the -Wl option, if there are multiple options behind it, you need to split it with a comma.

3.5 macro definition

3.5.1 Instruction format

Gcc -D'TEST="test"' file.c

3.5.2 Description

If the macro is a string, it needs to be enclosed in single quotes.

3.6 Obtaining the System Header Path

3.6.1 Instruction format

Gcc -v file.c

3.6.2 Description

The system header file refers to the C language itself and the operating system related header files. When using the -v option to get the system header file path, you must bring a valid C program source file, otherwise the information output by gcc will not contain the system header file path.

3.7 Generating dependencies

3.7.1 Instruction format

Get the full dependency of the target: gcc -M test.c Get the partial dependencies of the target: gcc -MM test.c

3.7.2 Description

Since the system header files are not changed in most cases, it is not necessary to include them in constructing the dependencies required by make. With the -MM option, you can have gcc generate dependencies that do not contain system header files.

3.8 Specifying the library file and library file search path

3.8.1 Instruction format

-L option: Specify the search path of the library file -l option: specify the library file ar crs libfunc.a func.o gcc test.c -L. -lfunc

3.8.2 Description

Note that the -L option tells gcc which directory to look up the library file from, and can use it multiple times to specify multiple directories; the -I option tells gcc which library name to link to when generating the executable. Options can also be used multiple times to specify multiple libraries. When using the -l option, be aware that the names that follow are not including the "lib" prefix and the ".a" suffix.

Vape Pods And Kits

TSVAPE, we bring in the best vape pod systems, pod kits for wholesaler and advanced vapers.Pod systems and pod kits are reshaping the trends of vaping industry to brilliance!
We provide products such as RELX,YOOZ,SNOWPLUS,FLOW,FOLI,LANA

Please contact us. If you are interested, we guarantee 100% original products at reasonable prices.

Relx Vape

Yooz Vape Pod

Foli Pro Device Pods

Vape Pods And Kits,Compact Vape Pod Kits,Pod Vape Kits,E Cigarette Pods And Kits

TSVAPE Wholesale/OEM/ODM , https://www.tsecigarette.com