In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to use the Gcc command under Linux, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand.
GCC means only GNU C Compiler. After so many years of development, GCC has not only supported C language; it now supports Ada language, C++ language, Java language, Objective C language, Pascal language, COBOL language, and Mercury language which supports functional programming and logical programming, and so on.
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. Example
Common compilation command options
Suppose the source program file name is test.c
No option compilation link
Gcc test.c
Preprocess, assemble, compile and link the test.c to form an executable file. No output file is specified here, and the default output is a.out.
Option-o
Gcc test.c-o test
Preprocess, assemble, compile and link the test.c to form an executable file test. The-o option specifies the file name of the output file.
Option-E
Gcc-E test.c-o test.i
Output the test.i file by preprocessing test.c.
Option-S
Gcc-S test.i
The preprocessing output file test.i is assembled into a test.s file.
Option-c
Gcc-c test.s
Compile the assembly output file test.s to output the test.o file.
No option link
Gcc test.o-o test
Link the compiled output file test.o to the final executable file test.
Option-O
Gcc-O1 test.c-o test
Use compiler optimization level 1 to compile the program. 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
Testfun.c and test.c are compiled separately and linked into 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, and unmodified files do not need to be recompiled.
Thank you for reading this article carefully. I hope the article "how to use Gcc commands under Linux" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.