Four-eye view of the world-building and using VIM + GCC + GDB in Ubuntu

Source: Internet
Author: User

This article will briefly introduce how to build and use VIM + GCC + GDB for C Programming in Ubuntu.

 

I. Installation

Run sudo apt-Get install Vim on the command line and enter the administrator password as prompted.

Run sudo apt-Get install build-essential in the same way.

 

Build-essential is a C language development kit that includes tools such as gcc gdb.

Ii. Instances

1. Compile the source file

Open the command line and enter Vim. Enter I to enter the vim insertion mode. Write code.

# Include <stdio. h> <br/> int main () {<br/> printf ("Hello Linux"); <br/> return 0; <br/>}

 

After completion, Press ESC to return to normal mode, and enter W helloworld. C to save the source file as helloworld. C (note that the file name in Linux is case-sensitive)

2. Compile

Enter :! Gcc-wall-G helloworld. C-o helloworld

 

-Wall option: displays warning information.

-G option: Add debugging information to the target file.

-O option: Specify the target file name. If this parameter is not specified, A. Out is generated by default.

If the compilation is successful, the helloworld file will be generated in the directory where the source file is located. Press any key to return.

3. debugging

Enter :! GDB helloworld To Start program debugging.

 

The following lists some common gdb commands:

L <n> output source code from line N to line N + 9

Break <n> set a breakpoint on line N

Info break

R running

N single-step execution

C. Continue execution

P varname output variable value

Q exit

Related Article

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.