Common options for compiling C programs using gcc

Source: Internet
Author: User

-O: Specify the target file name

-STD = c99 is compiled using the c99 Standard

-Wall warning Enabled

-C: Only compilation without link, generating intermediate files

-G generate debugging information

-O0: it is not optimized by default (if debugging information is to be generated, it is better not optimized)
-O1: simple optimization without the trade-off between speed and space;
-O2: further optimization, including scheduling. (This option is the most suitable for optimization. It is the default optimization level for GNU release software;
-O3: chicken ribs, probably making the program slower;
-Funroll-loops: Expand the loop to increase the number of executable files. Whether the speed increases depends on the specific environment;
-OS: generates the minimum execution file;


-LLibnameLink to a specified library

Note that GCC requires the database sequence of parameters during the database connection process. The database on the right of the parameter is loaded before the database on the left.

If you want to link the pthread library, the compilation command may be like this: gcc-STD = gnu99-wall-O Server *. C-lpthread

But it cannot be like this: gcc-STD = gnu99-wall-lpthrad-O Server *. C #-lpthread must be placed behind.


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.