1. Use of the VIM editor
2. GCC compilers
3. The creation of Static library--Lib
4. Creation of dynamic library--DLL
VI--VIM
Vim is a text editor developed from VI.
VI a.txt
Premise: The VIM software is installed
Operating mode:
1. Command mode-After opening the file, enter command mode by default
2. Edit mode-You need to enter some commands to switch to edit mode
3. Last-line mode-you can enter some commands in the last line mode
1. Use of the VIM editor
Operation in command mode:
1>. The movement of the cursor
H J K L
Before and after the top
Beginning of line: 0
End of line: $
File start Location: GG
End of File: G
Line Jump: 300G
2>. Delete operation
Delete the character behind the cursor: X
Delete the character in front of the cursor: X
Delete after the cursor Word: DW (cursor moves to the beginning of the word, no can delete only part)
Delete the cursor to the beginning of the string: D0
Delete the string at the end of the line: D (d$)
Delete cursor Current line: DD
Delete multiple lines: NDD (n--natural number)
3>. Undo Action
Undo: U
Anti-undo: Ctrl + R
4>. Copy and paste
Copy: yy
Copy Multiple lines: Nyy
Paste: P (the next line in the row where the cursor is located)
Paste: P (the line where the cursor is located)
Cut = = Delete
5>. Visual mode
Switch to mode: V
Select content: HJKL
Action: Copy: Y Delete: D
6>. Find operations
1)./hello (search down, back to tail)
2). Hello (look up, to head back to tail)
3). #--Move the cursor to the found word, press #
Shortcut keys for traversal: n/n
7>. R: Replace the current character
Indent:
Right: >>
Left: <<
8>. View the man document to specify chapters
3 SHIFT + K
Actions in text mode:
Switch to Text mode:
A--insert behind the cursor position
A--Inserts at the end of the current line
I--insert at the front of the cursor position
I--Insert at the beginning of the line where the cursor is located
O-Opens a new line below the line where the cursor is located
O-Opens a new line at the top of the line where the cursor is located
S--delete the character behind the cursor
S--delete the line where the cursor is located
Operations in the last-line mode:
:
Line jump: 123, jump to line 123th
Replace one line: s/abc/123, replace the first ABC in the current line with 123
: s/abc/123/g Replace all ABC in the current line with 123
Replace all:%s/abc/123, replace the first ABC in all rows with 123
:%s/abc/123/g Replace all ABC in all rows with 123
: 10,30s/abc/123/g, replace all ABC in line 10-30 with 123
Execute shell command in the last line mode input!, followed by command
Search: S/tom
Save exit:
Q: Exit
q!: Exit does not save
W: Save
Wq: Save exit
x: = = Wq
Save exit in command mode: ZZ
Last-line mode split-screen operation:
1>. Horizontal split screen: SP
2>. Vertical split screen: VSP
3>. Command: SP (VSP) + filename Horizontal or vertical splitter window shows two different files
CTRL+WW switching Two Screens
Command: Wq save and exit the screen where the cursor is located
Command: Wqall save and exit all screens
2. GCC compilers
1>. GCC Workflow: gcc hello.c-o Hello
Preprocessor CPP: Header file expansion, macro substitution, comments removed
GCC-E Hello.c-o hello.i
compiler gcc:c file into assembly file
Gcc-s Hello.i-o Hello.s
Assembler as: assembly file becomes binary target file
Gcc-c Hello.s-o hello.o
Linker LD: Combining function libraries into target files
GCC Hello.o-o Hello
2>. Some parameters of GCC use
1).-I specify header file directory
2).-C Only compiles subroutines
3).-O produces the target file of the specified name
4).-D compile-time definition macros
5).-G contains debug information (this parameter must be added when GDB debugs)
6).-wall Prompt for more warning messages
7).-O Compilation optimizations 0 to 3 levels
3. Making a static library
1>. Naming rules
1). lib + library name +. A
2). libmytest.a
2>. Production steps:
1). Generate the corresponding. o file--. C---o-c
2). Package the generated. o file with AR rcs + static library name (LIBMYTEST.A) + Generate all of the. O
3>. Publish and use a static library:
1). Publish a static library
The generated static library needs to be published at the same time as the corresponding header file
2). header file
GCC main.c lib/libmytest.a-i./-o app
GCC + source file +-L static library path +-L static library name +-I header file directory +-o executable file name
GCC main.c-l./-l mytest-i./-o app
3). The smallest unit of packaging to a program is. O
NM LIBMYTEST.A can see what the static library contains (executable files can also be viewed)
4>. Advantages and Disadvantages
Advantages: Convenient addressing, fast speed
Libraries are packaged into executable programs and can be used directly by publishing executable programs
Disadvantage: The code of the static library has been loaded into the executable program during the compilation process, so the volume is large.
If the static library changes, then your program must be recompiled.
4. Creation of shared libraries: (Dynamic Library)
1>. Naming rules:
1). lib + name +. So
2>. Production steps:
1). Generates location-independent code (generates a location-independent. O) parameter-fpic that generates a series of. o Files after the build is executed with the location-independent code
Gcc-fpic-c A.C B.C C.C
2). package. O into a shared library (dynamic library)
Gcc-shared-o libmytest.so a.o b.o c.o-i header file directory
3>. To publish and use a shared library:
GCC main.c-l./-l mytest-i include-o app
4>. Issue where the dynamic library could not be loaded when the resolver was executed:
The LDD app queries all shared libraries that the executable program needs to rely on when executing
found no path to dynamic Linker (LD-LINUX.SO.2) to specify a good libmytest.so
1). Copy to the system's library directory/lib/--no use allowed
2). Interim test
Environment variable: ld_library_path= Sets the path of the dynamic library to the variable
Import the value of the setting into the system environment variable: Export Ld_library_path
When the terminal is closed, the settings fail
3). Infrequently used methods (permanent settings):
Add a word to the. bashrc file in your home directory: Export ld_library_path= Absolute path to the dynamic library directory
. BASHRC modification completed, need to restart terminal
4).
1. Need to find the configuration file for the dynamic Connector--sudo vi/etc/ld.so.conf
2. The path of the dynamic library is written to the configuration file--Absolute path
3. Update--sudo ldconfig-v (output some information)
5>. Advantages and Disadvantages
Benefits: Save Memory (Shared)
Easy Update (dynamic link) Stop the program using the new library to overwrite the old library (ensure that the new and old library name is consistent, the interface is consistent) "interface" restarts the program.
Cons: Delayed binding, slightly slower speed
Publish a dynamic library to a user when publishing
Linux Learning Notes-BASIC Operations 3