linux compilation learning

1 Use the echo command to view a single environment variable. For example: 
e
o $PATH 
2 Use env to see all environment variables. For example: 
env 
3 Use set to view all locally defined environment variables.
4.so file: dynamic library
a file: static library
exe file: executable program (under linux, the file attribute is used to indicate whether it is an executable file, it has nothing to do with the suffix name)


When we compile programs with gcc, we often use "- I" (uppercase i), "-L" (uppercase l), "-l" (lowercase l) and other parameters, make a record below:


Example:
gcc -o hello hello.c -I/home/hello/include - L/home/hello/lib -lworld


1 The above sentence indicates that when compiling hello.c:
-I /home/hello/include, indicating that the /home/hello/include directory is used as the first directory to search for header files, and The order is: /home/hello/include–>/usr/include–>/usr/local/include


, which is the directory that specifies the priority search. If you can’t find it, look for the default directory
-L /home/hello/lib, which means that the The /home/hello/lib directory is the first directory to search for library files. The search order is: /home/hello/lib–>/lib–>/usr/lib–>/usr/local/lib


Same as above, also specified directory to look for
-l word , means **searching for the dynamic link library file**libword.so (that is, the library file represented by the prefix and suffix removed from the file name).


If the compile option -static is added, it means searching for the static link library file, which is libword .a
For the dynamic link library (.so) provided by a third party, generally copy it to a lib directory (/usr/local/lib), or use -L to specify its directory, and then use -l to specify its Name
5.gcc -g -o -c
g generates gdb
o followed by the execution file name
c only generates obj but not exe, only compiles without linking
-dl If you use a dynamic link library to add -ldl library  
-lxxx l means lib, Followed by the library name
gcc -g -o add add.c -lm -llua -ldl --database
for
  update lock can only be automatically unlocked after commit or rollback. So the final processing in the stored procedure must be commit or rollback


6. Int to negative number binary completely inverse, plus 1 is a negative number
7. Delete files and folders under Linux (rm)
Delete directory, file rm (remove)


Function description: delete a file or directory.
Syntax: rm [-dfirv][--help][--version][file or directory...]
Supplementary description: Execute the rm command to delete a file or directory. If you want to delete a directory, you must add the parameter "-r", Otherwise the preset will just delete the file. 
Parameters:
 -d or –directory directly delete the hard link data of the directory to be deleted to 0, and delete the directory. 
 -f or –force Force deletion of a file or directory. 
 -i or --interactive Ask the user before deleting existing files or directories. 
 -r or -R or --recursive Recursive processing, processing all files and subdirectories in the specified directory together. 
 -v or –verbose Display instruction execution process. 


 It is very simple to delete a directory in linux. Many people are still used to using rmdir, but once the directory is not empty, they will fall into deep distress.
Now use the rm -rf command.


gdb prints the complete string
set print element 0

Guess you like

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