Linux study notes. C language programming in linux
Source: Internet
Author: User
Linux study notes. C language programming in linux-Linux general technology-Linux programming and kernel information. The following is a detailed description. 11. C language programming in linux
Step: 1. $ vi hello. c
2. Input Source Code
# Include
Main ()
{
Printf ("hello, linux! ");
}
3. Pre-processing $ gcc hello. c-o hello. I-E (you can use vi to view each generated file)
4. Compile $ gcc hello. I-o hello. s-S
5. Compile $ gcc hello. s-o hello. o-c
6. Link $ gcc hello. o-o hello
7. run $./hello
The displayed result is hello, linux!
You can also run the $ gcc hello. c-o hello command in one step (you can also add the-g parameter to the end to facilitate future gdb
Debugging)
Note: 1. Pay attention to the writing of Chinese and English characters (double quotation marks and single quotation marks)
Common gcc Parameters
-C: Only compilation is not linked, and the target file is generated.
-S: Only compilation without assembly, producing assembly code
-E only performs preprocessing.
-G contains debugging information in the executable program
-O file: output the file to the file.
-V indicates the gcc version.
-I dir: add the dir directory to the header file search (dir is the absolute path)
-L dir: add the dir directory to the database file search (dir is the absolute path)
-Static Link static Library
-Library: link the library file named library
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