In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
01. command overview
The gcc command uses GNU's C/C++-based compiler, which is the most widely used compiler in the open source field. It has powerful functions and compiles code to support performance optimization.
gcc is the GNU Compiler Collection, which includes frontend languages for C, C++, Objective-C, Fortran, Java, Ada, Go, and D, as well as libraries for these languages (libstdc++, libgcj, etc.). GCC was originally written as a compiler for the GNU operating system. The GNU system is completely free software. Here,"freedom" means that it respects the user's freedom.
02. command format
Usage: gcc [options] file...
03. common options
-pass-exit-codes Returns the highest error code when exiting a stage--help Show this help description--target-help Show target machine-specific command line options--help={common| optimizers| params| target| warnings| [^] {joined| separate| undocumented}}[,...] Display command-line options for specific types (use '-v --help' to display command-line arguments for child processes) --version Show compiler version information-dumpspecs Show all built-in spec strings-dumpversion Show compiler version number-dumpmachine Show compiler target processors-print-search-dirs Show compiler search path-print-libgcc-file-name Show compiler companion library name-print-file-name= full path to display-print-prog-name= full path to display compiler component-print-multiarch Display the target's normalized GNU triplet, used as a component in the library path -print-multi-directory Displays the root directory of different versions of libgcc-print-multi-lib Show mappings between command-line options and multiple repository search paths-print-multi-os-directory Show relative paths to OS libraries-print-sysroot Show target library directory-print-sysroot-headers-suffix Show sysroot suffix-Wa used to find header files, Comma separated passes to assembler-Wp, Comma separated is passed to preprocessor-WL, Pass comma separated to linker-Xassembler Pass to assembler-Xpreprocessor Pass to Preprocessor-Xlinker Pass to linker-save-temps Do not delete intermediate files-save-temps= do not delete intermediate files-no-canonical-prefixes do not generate canonical when generating relative paths to other gcc components Prefix-pipe Use pipes instead of temporary files-time Time each child process-specs= overwrite the built-in specs file with the contents of-std= Specifies criteria followed by input source files--sysroot= -B will be the root directory for header and library files will be added to the compiler's search path-v Show programs called by compiler-### Similar to-v, but options are enclosed in quotes and the command-E is not executed Preprocessing only, no compilation, assembly and linking-S Compile to assembly language without assembly and linking-c Compile, assemble to object code without linking-o Output to-pie Create a position independent executable -shared Create a shared library -x Specifies the language in which the file is input afterwards Allowed languages include: c c++ assembler none 'none' means reverting to default behavior, i.e. guessing from file extensions Language of source file
04. Reference Example
4.1 Generate default executable file
[deng@localhost bak]$ gcc test.c [deng@localhost bak]$
Test.c is preprocessed, assembled, compiled and linked to form an executable file. No output file is specified here, the default output is a.out.
4.2 specify the output file
[deng@localhost bak]$ gcc test.c -o test[deng@localhost bak]$ ls5th 6th 7th 8th 9th test test.c[deng@localhost bak]$
Preprocess, assemble, compile, and link test.c to form the executable test.c file. - The o option specifies the filename of the output file.
4.3 Pre-processing only, no compilation, assembly and linking
[deng@localhost bak]$ gcc -E test.c -o test.i [deng@localhost bak]$
Preprocess test.c to output test.i file.
4.4 Compile to assembly language without assembly and linking
[deng@localhost bak]$ gcc -S test.c -o test.s[deng@localhost bak]$ ls5th 6th 7th 8th 9th test test.c test.i test.s[deng@localhost bak]$
Assemble the preprocessing output file test.i into a test.s file.
4.5 Compile, assemble to object code without linking
[deng@localhost bak]$ gcc -c test.c -o test.o[deng@localhost bak]$ ls5th 6th 7th 8th 9th test test.c test.i test.o test.s[deng@localhost bak]$
4.6 Generate executable files from object code
[deng@localhost bak]$ gcc test.o -o test[deng@localhost bak]$
Link the compiled output file test.o into the final executable file test.
4.7 Specify optimization level at compile time
[deng@localhost bak]$ gcc -O1 test.c -o test[deng@localhost bak]$
Compile the program using compilation optimization level 1. Level 1~3, the higher the level, the better the optimization effect, but the longer the compilation time.
4.8 multifile compilation
[deng@localhost bak]$ gcc testfun.c test.c -o test[deng@localhost bak]$
Compile testfun.c and test.c separately and link them to the test executable file.
4.9 Multifile Compilation Method II
[deng@localhost bak]$ gcc -c test.c [deng@localhost bak]$ gcc -c testfun.c [deng@localhost bak]$ gcc test.o testfun.o -o test[deng@localhost bak]$
This article on the specific use of Linux gcc command on the introduction of this article, more relevant Linux gcc command content please search the previous article or the following related articles, I hope you will support more in the future!
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.