Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the parameters of the Linux gcc command

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article focuses on "what are the parameters of the Linux gcc command". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn what are the parameters of the Linux gcc command.

The common command gcc command of Linux uses the compiler based on Champact + developed by GNU, which is the most widely used compiler in the open source field. It has the characteristics of powerful function, and the compiled code supports performance optimization.

The Compiler of gcc based on CumberCraft +

Add that many programmers now use GCC, how to better apply GCC. At present, GCC can be used to compile programs in languages such as CAccord +, FORTRAN, JAVA, OBJC, ADA, etc., and you can choose which languages to install according to your needs.

Syntax gcc (options) (parameters) option-o: specify the generated output file;-E: perform compilation preprocessing only;-S: convert C code to assembly code;-wall: display warning messages;-c: only compile operations, not concatenation operations. Parameter C source file: specify the C language source code file.

Common compilation command options for instances

Suppose the source program file name is test.c

No option compilation link

Gcc test.c preprocesses, assembles, compiles, and links test.c into executable files. No output file is specified here, and the default output is a.out.

Option-o

Gcc test.c-o test preprocesses, assembles, compiles, and links test.c into an executable file test. The-o option specifies the file name of the output file.

Option-E

Gcc-E test.c-o test.i preprocesses the test.c to output the test.i file.

Option-S

Gcc-S test.i assembles the preprocessed output file test.i into a test.s file.

Option-c

Gcc-c test.s will compile the output file test.s and compile the output test.o file.

No option link

Gcc test.o-o test links the compiled output file test.o to the final executable file test.

Option-O

Gcc-O1 test.c-o test compiles the program using compilation optimization level 1. The level is 1-3, the higher the level, the better the optimization, but the longer the compilation time.

Compilation method of multi-source files

If you have multiple source files, there are basically two compilation methods:

Suppose you have two source files, test.c and testfun.c

Multiple files compiled together

Gcc testfun.c test.c-o test compiles testfun.c and test.c separately and links them to test executable files.

Compile each source file separately, and then link the compiled output target file.

Gcc-c testfun.c # compiles testfun.c to testfun.ogcc-c test.c # compiles test.c to test.ogcc-o testfun.o test.o-o test # links testfun.o and test.o to test compared with the above two methods, the first method requires all files to be recompiled, while the second method can only recompile modified files without recompiling unmodified files.

At this point, I believe you have a deeper understanding of "what are the parameters of the Linux gcc command?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report