Summary of the second week's learning content

Source: Internet
Author: User

Duration of study: 6 hours

• Learning Tasks

1. Enter the tutorial at Terminal input Vimtutor to learn the basic operation of VIM

2. Compile the. c file using Gcc,gdb

3. Learn to use Makefile to put multiple files in one folder

Two · learning methods

In this week's experiment, learning to use a Linux-like Mac OS is easy to use on air, learning about this week's content through the knowledge of chapter III of the book on the experimental building and the PDF.

Three • learning process

1. Basic operation of VIM

Enter Vimtutor in the terminal to enter the tutorial. In the tutorial learned to use some basic instructions, such as open a new file and press the I key to enter text, press ESC to exit a mode, and then enter:, and then enter WQ to save the exit. Then there are some commonly used, such as the LS display file directory, in normal mode, press the X key to delete the cursor corresponding text, and so on.

2. Compiling with GCC

before compiling, first enter the vim file name + suffix name, you can create the corresponding file (for example, I want to create a hello.c, as long as the input vim hello.c), and then enter the way to use the teaching of vim to enter the code. After entering the code, enter the GCC directive, it can directly convert. c files into. o files, in fact, in the process there are. i suffix file, after compiling with vim to look at, the results are as follows:

Figure: Entering GCC directives for compilation

Figure: Content in the. I file

Figure: Content in the. o File

Figure: Results of normal compilation of file hello.c

3. Debugging with GDB

GDB as a program to debug the program, but in the Mac OS does not, so in the online search has been installed, is still in the terminal input instructions, installation success because of the protection of MAC system, need to be certified, search on the Internet, the certificate is not certified after writing, still in the process, But some instructions can also be used, some in the job.

Some common directives in GDB are: (1) Break 6 (6 is the line number of the breakpoint); (2) Info Break (view breakpoint information)

(3) R (running program) (4) N (Single step operation)

(5) P I (the value of the print variable i) (6) C (continue to run the program)

4. Learn to use Makefile

Makefile defines a set of rules to specify which files need to be compiled first, which files need to be compiled, which files need to be recompiled, and even more complex functional operations.

In Vim, the final "clean:" is used to make the clean to execute the rm-f *.O Test command, complete the clean operation.

In the final job, there are some problems running, which are explained in detail in the job.

5. Job

(1) First VIM writes the corresponding file, then compiles it using GCC and then runs in the terminal.

(2) Debugging with GDB

After trying other sets of data, the output of the division is 0 regardless of how the data is transformed. Because the computer gdb has some problems, can only run some instructions, the result is as follows:

Figure: Enter GDB after entering L, view code and number of lines

In , just set the breakpoint and view the breakpoint information, both the input run and the single step run are errors, still learning debugging.

(3) Setting up static and dynamic libraries

Install the knowledge on the PDF instruction book and enter the corresponding instructions to complete.

Figure: Static Library

Figure: Dynamic Library

(4) using makefile

The installation instructions on the Vim compile, the results are as follows:

However, after you enter the Make command, you are prompted with an error, no problem is found after viewing, and you are still trying to resolve it.

Four · Learning Summary

This week's study provides a deeper understanding of the compilation of the terminal-finished code in Mac OS. Vim's learning let me from the original file after the confusion, to now can compile a number of files composed of programs, and debugging and static library creation. Through learning, Apple's own system to write code has a deep understanding, and finally did not like before the other system to idle.

Summary of the second week's learning content

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.