Embedded system development study notes (3)

Last review

Embedded system development study notes (2)

Embedded system development

Linux file operation commands

Command
1. gcc -Wall displays all warnings
2. cp …/file name. Copy the upper-level directory file to the current directory

Library file description

Library files (stored in the lib folder): warehouses for storing functions and variables.
Features: You can only use the functions and variables in the library, and you can't see its implementation.
Static library (usually ending with .a): When using a static library, the functions and variables in the library are loaded into the executable file at compile time.
Dynamic library (usually ending with .so): When using a dynamic library, the functions and variables in the library are loaded into the executable file at runtime.
Advantages and disadvantages:
1. Executable file size: static library> dynamic library (refers to memory usage efficiency)
2. Executable file speed: static library> dynamic library (refers to operating efficiency)
3. Executable file upgrade: dynamic library> static Library (referring to the difficulty of function upgrade)
4. Code deployment of executable files: Static library>Dynamic library (referring to the location of code deployment)
"File name": This type of file is searched in the current directory and cannot be found. Look for them in turn.
<File>: Search for such files in the lib library
. The storage path of the library files: /lib/usr/lib

Production of static library

1. gcc -c source file
2. ar rcs library file name target file
3. gcc source file -l library name-L library name path
Example: create addition and subtraction static library files
Insert picture description here
Insert picture description here

Create add.c algorithm file

Insert picture description here
Insert picture description here

Create minus.c algorithm file

Insert picture description here
Insert picture description here

Create and write add.h minus.h file

Insert picture description here

Convert .c files to .o files

Insert picture description here

Insert picture description here

Convert algorithm to library file

Insert picture description here

Insert picture description here

Generate executable file

Insert picture description here

Run the file to output

Dynamic library production

1. gcc -shared -fPIC source file -o library name
2. gcc source file./library name -o executable file

Guess you like

Origin blog.csdn.net/m0_52251623/article/details/114651348