In Linux, gcc is used for compilation, gdb is used for disassembly of C language programs, and gccgdb

Source: Internet
Author: User

In Linux, gcc is used for compilation, gdb is used for disassembly of C language programs, and gccgdb
Use the Virtual Machine VMware Workstation 10Linux environment: Ubuntu 14.04 LTS Server amd64

The process is as follows.

The first is the hello world Program. Note: The gcc-o parameter specifies the file name of the generated program. In gdb, The disas command corresponds to discycler in English, which is disassembly. No program is executed here. If you want to execute the command, the following error occurs:

Shen @ ubuntu :~ $./Helloworld

Hello World!

Shen @ ubuntu :~ $

 

Of course, you need to add./to search for the helloworld file in the current directory for execution.

A slightly Complex C Language Program: (I have made a few attempts)
In linux, how does one program in C language? Where can I write the code and save it in what format?

Under the terminal
Input
Vi a. c
Write
# Include <stdio. h>
Int
Main ()
{
Printf ("Hello World \ n ");
}
Press Esc again
Then press Shift + ZZ to save
Enter
Gcc a. c
Again
./A. out
You can.
You can see
Man gcc

How to Build the vim + gcc + gdb environment in a linux system? This person is not familiar with the system when installing linux.

What is "Build" and build a bridge?-) These are basic programming tools in Linux. To write code, use Vim, but not necessarily use it. I prefer emacs, and gedit, both of which are good. vim is classic and older than emacs. These are all editors. gcc is the longest-used compiler used to compile C language programs, but there are cc, it is a fossil in UNIX. Generally, it is essential for POSIX systems such as Linux, BSD, FreeBSD, and openBSD. Once the program is made, it cannot be a single error. Therefore, you can use gdb for debugging, gdb is a very good debugging (remember to add the parameter "-g" in gcc when using it), not only can you view the value of a variable, but also can see the register equivalent, besides gdb, kdb and kgdb are available.

I don't know which release you are using. The Redhat series (redhat, fedora, SUSE) use the following command:
Su
Yum install gcc gdb vim
If there is an RPM package:
Rpm-ivh gcc-xxxxx.rpm
Rpm-ivh gdb-xxxxx.rpm
Rpm-ivh vim-xxxxx.rpm
Run the following command to Debian (Unbuntu:
Sudo apt-get install gcc gdb vim
If deb package exists:

Sudo dpkg-I gcc-xxxx.deb
Sudo dpkg-I gdb-xxxx.deb
Sudo dpkg-I vim-xxxx.deb

If a new version is installed, a small prompt is displayed. If a new version is installed, the version is updated.

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.