Linux Learning C language (1)------source program compilation

Source: Internet
Author: User

These days to learn some of the Linux knowledge, your own study notes, recorded here, in order to motivate themselves to progress.

GCC is the best compiler to look at how to compile a simple C program using GCC:

hello.c

#include <stdio.h>int main () {printf ("Hello c!\n");}
To compile this simple program, you only need to execute it under the terminal.

Gcc-o Hello hello.c

In this way, the GCC compiler generates a hello executable file;

To see how the program performs, you only need to execute it under the terminal

./hello

You can see the results of the program output.

Explanation: GCC in the command indicates that the compiler we are using is GCC

-O indicates that the compiler is required to output the executable file, followed by the output executable file name

HELLO.C means our source program.

In fact, the GCC compiler has a number of options, and generally we just need to know how many of them are enough. The-o option we already know, indicates the executable file name we are asking for output. The-c option means that we only require the compiler to output the target code, not the necessary output of the executable file. The-G option indicates that we are asking the compiler to provide us with information for debugging the program at compile time.

In the next section, learn some more about GCC.
  



Linux Learning C language (1)------source program compilation

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.