Linux Common Tools (ii) __linux

Source: Internet
Author: User

(ii) GCC tool chain

1.GCC is the GNU Compiler collection The GNU compiler family

2. Simple compilation

Example: #include <stdio.h>

int main ()

{

printf ("Hello world!\n");

Return0;

}

Compile instruction gcc Test.c-o test to generate the test executable./test execution

3. Compile Four Stages

(1) Preprocessing (header file expansion)

Example: Gcc-e test.c-o test.i

(2) Compile (grammar check, convert C language into assembly language)

Example: Gcc-s test.i-o Test.s

(3) compilation (Translate assembly language into binary file)

Example: Gcc-c test.s-o TEST.O

(4) Link (link binary file to library)

Example: GCC test.o-o test

4. Compilation of multiple Program Files

Example: GCC test1.c test2.c-o test

5.GCC Common Instructions

-C: Just compile not connected, generate target file ". O"

-S: Just compile not assembler, generate assembly code

-E: precompiling only, no other processing

-G: Include standard debugging information in an executable program

-o File: Export output to File

-I dir: add dir directory to the search path list of header files

-static: Link Static Library

-I library: link Libraries file

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.