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.