If you want to learn the basic operations in linux again, you should be familiar with the commands.
Repeat the state-embedded experiment. Although I have done it before, I have not made any records, so I feel a little confused now, so starting with gcc:
1. Compile an application, use gcc for compilation, and use the-o,-g,-static,-O2 options respectively.
Release 1.c
Ipv2.c
1. Execute the command gcc prepare 1.C prepare 2.c to generate the. out executable file by default.
2. Run the command gcc running 1.C running 2.c-o a to specify the file name a for generating the executable file, which has the same effect as 1.
3. Execute the command gcc-g release 1.C release 2.c-o a to generate an execution file with debugging information.
4. Execute the command gcc-static prepare 1.C prepare 2.c-o B to generate file B. But through the ls-l command, we can find that the size of file a and file B is different, as shown below:
Therefore, the latter is bound to a library file and is connected to a static library!
5. The command gcc-O running 1.C running 2.c has not found any benefits for the moment!
2. debug the GDB program. Compile an application and use gdb for debugging. Use all the commands described in this section during debugging. Compile the test program as follows:
1. Execute the command gcc-g prepare 1.C to generate the. out file with debugging information.
2. Execute the command gdb a. out to enter the debugging status! First, you can run the list (l) command to view the program to be debugged.
3. break (B) function name: indicates a breakpoint at the function entry. break (B) row number: indicates a breakpoint at the row.
Break (B) file name row number (function name): indicates that a breakpoint is triggered at the row number (function) specified by the specified file name.
4. run (r): directly run
5. next (n): indicates to execute the next step without entering the sub-function.
6. step (s): Indicates entering the subfunction and performing the next step in a single step.
7. continue (c): indicates that the program continues to run.
8. print (p) variable name: displays the value of the current variable.
9. watch variable: monitor the current variable
11. quit (q): Exit program debugging
12. start starts to run the main function.
13. backtrace command (bt): You can view the stack frames of function calls.
14. Run the current function on finish until the call is returned.
10. Use of GNU make
Write the following three programs:
You can use the command line method for compilation. It does implement the function of comparing the size.
Type vimmakefile
Enter the following content
Important Notes:
$ <: Indicates the first dependent file.
$ @: Indicates the current target.
$ ^: Indicates all dependent files
# The following content in Makefile indicates comments
@ Indicates canceling echo.
. PHONY indicates declaring a pseudo target