微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > gcc的几个妙用

gcc的几个妙用

时间:12-01 来源:互联网 点击:
gcc的学习在C接触到linux以后就开始不断的学习,也知道了一些基本的用法,但是关于gcc的使用还是有很多值得我们加深的地方。gcc 只是一个编译工具而已。也就相当于我们在windows环境下的visual c++等一样,区别是visual c++是基于IDE的,而gcc是这些IDE的基础。学习linux程序设计必然会学习gcc。

gcc实质是完成程序的编译和链接,程序的编译是指从一种文件类型转换到另一种文件类型的过程。一个C语言程序转换为可执行程序的基本步骤如下:

1、编写程序(vi,emacs等软件)

2、程序预编译(cpp)

3、编译成汇编程序(cc)

4、汇编程序(as)

5、链接程序(ld)

其中的这些过程都已经被gcc包含,我们在实际的编译过程中采用了gcc main.c -o main.exe即可实现一个程序的编译和链接。并不需要一步一步的实现,但是我们在分析的过程中又必须注意一个C语言文件的处理过程以及相应的处理程序。

关于gcc的基本含义用法就不再详细的说明了,我觉得最简单的使用方法是通过软件的help学习软件。

[gong@Gong-Computer test]$ gcc --help
Usage: gcc [options] file...
Options:
-pass-exit-codes Exit with highest error code from a phase
--help Display this information
--target-help Display target specific command line options
--help={target|optimizers|warnings|params|[^]{joined|separate|undocumented}}[,...]
Display specific types of command line options
(Use -v --help to display command line options of sub-processes)
--version Display compiler version information
-dumpspecs Display all of the built in spec strings
-dumpversion Display the version of the compiler
-dumpmachine Display the compilers target processor
-print-search-dirs Display the directories in the compilers search path
-print-libgcc-file-name Display the name of the compilers companion library
-print-file-name= Display the full path to library
-print-prog-name= Display the full path to compiler component
-print-multi-directory Display the root directory for versions of libgcc
-print-multi-lib Display the mapping between command line options and
multiple library search directories
-print-multi-os-directory Display the relative path to OS libraries
-print-sysroot Display the target libraries directory
-print-sysroot-headers-suffix Display the sysroot suffix used to find headers
-Wa, Pass comma-separated on to the assembler
-Wp, Pass comma-separated on to the preprocessor
-Wl, Pass comma-separated on to the linker
-Xassembler Pass on to the assembler
-Xpreprocessor Pass on to the preprocessor
-Xlinker Pass on to the linker
-combine Pass multiple source files to compiler at once
-save-temps Do not delete intermediate files
-save-temps= Do not delete intermediate files
-no-canonical-prefixes Do not canonicalize paths when building relative
prefixes to other gcc components
-pipe Use pipes rather than intermediate files
-time Time the execution of each subprocess
-specs= Override built-in specs with the contents of
-std= Assume that the input sources are for
--sysroot= Use as the root directory for headers
and libraries
-B Add to the compilers search paths
-b Run gcc for target , if installed
-V Run gcc version number , if installed
-v Display the programs invoked by the compiler
-### Like -v but options quoted and commands not executed
-E Preprocess only; do not compile, assemble or link
-S Compile only; do not assemble or link
-c Compile and assemble, but do not link
-o Place the output into
-x Specify the language of the following input files
Permissible languages include: c c++ assembler none
none means revert to the default behavior of
guessing the language based on the files extension

Options starting with -g, -f, -m, -O, -W, or --param are automatically
passed on to the various sub-processes invoked by gcc. In order to pass
other options on to these processes the -W options must be used.

For bug r

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top