Embedded design courses (3)

Embedded Linux development tools and course objectives

vim (text editor) to learn how to use and configure vim
gcc (compiler) how to make dynamic and static libraries and use the difference between
gdp (debugger) set off, single-step execution, debug memory error
writing make (project manager) the makefile

Linux text editor: vim- most powerful text editor - get rid of the mouse

vi-vim-gvim: command-line mode nyy \ p \ ndd \ u, insert mode i, a, line mode: + Shift
(enter i or a quit esc save: wq Copy Paste Delete recovery yy p dd u)
configuring vim? / etc / vim / vimrc
IDE (Integrated Development Environment) -vscode

Embedded Linux Development Tools -gcc

Compiler: gcc (GNU CC)
1, features gcc (GNU tools, cross-compiler)
** What is a cross-compiler? ** Why do we need a cross-compiler?
Cross compiler: In the current CPU platform compiled executable other CPU platform code in other
source files into executable files which need to go through several steps?
Preprocessing, compiler, assembler, linker
Pretreatment: Expand the header file (<> Search Path: header file directory / usr / the include
"" Path search elements: first looks in the current directory, and then can not find the file directory system Find) macro substitution, conditional compilation
-E only pretreatment (suffix .i) -E hello.c gcc
-S compilation stage stop
after the -c assembler to stop
-o rename the executable file
-I specifies the header file first tripartite search path
-D external to the internal definition of
the compiler: the preprocessed file compiled into an assembly file -S .s
-O1 -O2 -O3 compiler optimization
assembler: assembler files compiled object files .o -c
links: create a symbolic table - the executable file the a.out
-Wall warning level increase
-w off warning gcc hello.c -w -o hello
system migration: host <cross compiler> target

Production of static and dynamic libraries

1. What is a library? Saving functions and variables (warehouse)
features: save the functions and variables, only use but can not see its implementation
2, Linux libraries:
static library .a: loaded at compile time; (the code library file is loaded into the source file )
dynamic libraries .so: loaded at runtime;
there are differences (pros and cons) resulting executable file
1. use static library generated executable file> dynamic libraries generated executable file (program running memory occupied more)
2 using static library generated executable file is difficult to upgrade; dynamic libraries generated executable file is easy to upgrade;
fast static library 3. use the generated executable file running speed; dynamic libraries generated executable file runs slowly
4. static library files using the executable code is easy to deploy, difficult to deploy dynamic library;

3, Linux library file storage path :( automatically search path)
\ lib: storage system running the required libraries
\ usr \ lib: storage is needed to run the program library

How to make a static library?

1, the file will need to save a function where the compiled object file -c add.c gcc -> add.o
2. static library authoring tools: Ar
Ar RCS (does not exist is created, there is updated) target library name file name
Ar RCS libadd.a add.o
(libadd.a cp / lib or / usr / lib
3. use
gcc source file name -l library path -L inventory release of
gcc main.c -ladd -L. -o add

How to make a dynamic library?

gcc -shared -fPIC libcal.so source file -o
gcc -shared -fPIC add.c sub.c -o libcal.so

operation

gcc -static this static role? ?
1, hide
when compiling multiple files at the same time, not all of the prefix plus static global variables and functions have global visibility
2 to keep the contents of variables persistent: variables are stored in the static data area will be completed at the beginning of the program running initialization, and only time initialization, (static local variable will only be modified automatically released when the entire end of the program. If the function of the local variables where the next call, it does not require re-statement, and will retain the last time call deposit value.)
3, static variables are not initialized, initialized by default 0
the third role is the default static initialized to zero. In fact, global variables also have this property, because global variables are stored in the static data area. In the static data area, in memory of all the bytes default values are 0x00, sometimes this feature can reduce the workload of programmers.
do three sentence summary of the role of static. The first static main function is hidden, and secondly because static variables stored in static memory, so it has the persistence and the default value of 0.

Preview gdb make (link attached)
https://blog.csdn.net/yulong__li/article/details/88049047

Released five original articles · won praise 2 · Views 123

Guess you like

Origin blog.csdn.net/qq_43312538/article/details/104873659