3.Linux development tools

1. What is yum tool

the app store

1. vim - file compiler

 what is vim?

Answer: file compiler, used for code writing

Feature is a multi-mode compiler that defaults to command mode.

There are 12 modes commonly used, and we need to master three modes at present. respectively

    Command (Normal) Mode: Execute various commands

              Insert (edit) mode: used to enter code

              Bottom line mode: Currently used to save (w) and exit (q)

1. First understand the switching between modes, how to enter insert mode from normal mode? (three ways)

① Enter i to enter insert mode (the cursor does not change)

② Enter a to enter the insert mode (the next position in the same line)

③ Enter o to enter insert mode (change to the next line)

And how to go back? Answer: Insert -> Command esc

How to enter bottom row mode? Answer: To enter the bottom line, you need to perform shift+ from the insert mode; that is, enter the insert mode:, vim can exit wq from the bottom line

In bottom line mode, set nu displays the line number.

Some common commands in command mode

yy: copy the current line nyy: copy n lines

p: paste to the next line np: paste n lines

u: undo the last action

dd: cut the line where the cursor is located ndd cut n lines

gg: position the cursor at the beginning of the file

shift+g: position the cursor at the end of the file n, shift+g, position the nth line

shift + 4($) : position the cursor at the end of the current line

shift + 6(^) : position the cursor at the beginning of the current line

b,w, move forward according to the word, move backward nb,nw

x,nx delete text content

hjkl, left (h) down (j) up (k) right (l)

bottom row mode

/find text

ctrl + w twice quickly to switch windows

vim test.c + 8 cursor is positioned near the error

zz: save and exit

ctrl + r Undo

2. gcc

Preprocess, compile, assemble, link

Let's understand what the above four steps do

preprocessing

  • Do macro substitution, file inclusion, conditional comments, decomment, etc.
  • Actual operation: gcc -E hello.c -o hello.i
  • -E is to stop the compilation process after the preprocessing is over (end means)
  • -O refers to the object file (object), the i file is the preprocessed file

compile

  • At this stage, gcc will first check the correctness of the code, and then translate the code into assembly language.
  • Actual operation: gcc -S hello.i -o hello.s
  • -S Generate assembly code, but only compile, not assemble.

compilation

  • This stage is to convert the .s file generated in the compilation stage into code that can be recognized by the machine.
  • Actual operation: gcc -c hello.s -o hello.o
  • Use -c to see that the assembly code has been converted into .o binary object code

Link

  • Generate executable.
  • Actual operation: gcc hello.o -o hello

1. Linux has two kinds of libraries, one is static library (libxxx.a) and the other is dynamic library (libxxx.so). When gcc is statically linked, the default is dynamic linking. Generally, when linking, the library you are looking for is . so. Static link to find .a. If a linking error occurs, you should first confirm whether the corresponding library exists.

-E only activates preprocessing, this does not generate a file, you need to redirect it to an output file
-S compile to assembly language without assembling and linking
-c compile to object code
-o file output to file

How does the compiler find various libraries?

When you use a library, what are you actually using?

How to generate the library?

Linux environment can run most languages

3. Linux debugger - gdb use

ctrl r history command search

The executable program generated by Linux by default is dynamically linked and released as a release version

-g release in debug mode

gdb   file.c-d

Some common commands

list l displays the source code, 10 lines at a time

breakpoint b breakpoint 

info b breakpoint information

p print

4. make/makefile - Linux project automation build tool  

The makefile is equivalent to writing dependencies and methods for direct use during operation.

Dependency: It determines whether it can be done or not, invisible in life. indicate dependent objects

Dependency method: decides how to do, what I want to do.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324331852&siteId=291194637