gcc - GNU project C and C++ compiler

 
gcc [option] file...

           preprocessing         compilation               assembly       linking
.c(with macros)--->.c(without macros)--->assembler input file--->object file--->executable file
 
-E, -S, -c 告诉在编译哪个阶段停止。
              -E 在执行 preprocessing 后停止,产生标准输出。
              -S 在执行 compilation 后停止,产生 .s 文件。
              -c 在执行 assembly 后停止,产生 .o 文件。
 
-std 指定编译器使用的标准。常用标准:c90, c89(就是c90), c99, gnu90(default), gnu99, c++98, gnu++98。示例:-std=c90。
              -ansi for C code 等价 -std=c90。-ansi for C++ code 等价 -std=c++98。
 
-pedantic Issue all the warnings demanded by strict ISO C and ISO C++;
               reject all programs that use forbidden extensions, and some other programs that do not follow ISO C and ISO C++.
               需配合 -std 或 -ansi 使用。
 
-g 添加标准调试信息。另一个选项 -ggdb,添加对 gdb 更友好的调试信息。
 
-pg 当想使用性能分析工具 gprof 时,需要添加该选项。
 
-O 优化(Optimize)。常用可选值:-O0(default), -O1(等价 -O), -O2(一般使用的优化级别), -O3, -Os(针对空间优化)。
 
-Wall 开启所有提醒。-Werror 把提醒当作错误。
 
-I 添加 include 目录。
-L 添加 lib 目录。
-l 将库文件添加到链接过程中,默认是链接 shared libraries。下面是为什么把 -l 放到命令行最后的原因。
           It makes a difference where in the command you write this option;
           the linker searches and processes libraries and object files in the
           order they are specified.  Thus, foo.o -lz bar.o searches library z
           after file foo.o but before bar.o.  If bar.o refers to functions in
           z, those functions may not be loaded.
-static 强制使用 static linking 来链接库(gcc 默认使用 shared linking, 不成功再试用 static linking)。链接库时有两种选择:static linking(*.a, archive file), dynamic linking(*.so, shared object)。
 
-shared
           Produce a shared object which can then be linked with other objects
           to form an executable.
 
-Dmacro[=defn] 定义 macro。
-U 取消 macro 的定义。该 macro 可以是 either built in or provided with a -D option。
试验 https://gist.github.com/4277550, -D #define, -U #undef
 
-o 定义 output 文件名。
 
-f Options of the form -fflag specify machine-independent flags.应该不常用吧。
      -fPIC emit position-independent code, suitable for dynamic linking and avoiding any limit on the
           size of the global offset table. 
-m   Each target machine types can have its own special options, starting

with -m, to choose among various hardware models or
       configurations---for example, 68010 vs 68020, floating coprocessor or
       none.  A single installed version of the compiler can compile for any
       model or configuration, according to the options specified.应该不常用吧。

 
将 option 传给链接器:
gcc -Wl,a,b -> ld a b
-Wl,a,b=-Wl,a -Wl,b
 
man gcc  开头一段指明的常用的选项,不错。但整个文档的体积太大了。确实没法看完。
http://www.antoarts.com/the-most-useful-gcc-options-and-extensions/ 对如何学习 gcc 有介绍,对常见选项有介绍,其中运行时检测没试出来

最新文章

  1. CF2.BC
  2. 《Invert》开发日志05:终止
  3. September 19th 2016 Week 39th Monday
  4. sqlserver 存储过程 以及统计整个数据库数据
  5. SQL Server数据库(SQL Sever语言 事务)
  6. 【MongoDB】增删改查基本操作
  7. mysql 中的数据类型
  8. Python 安装、循环语句、数据类型(一)
  9. stm32串口接收中断协议解析
  10. 用Java实现栈结构
  11. keras04 GAN simple
  12. RHEL7下用本地光盘或镜像iso文件做yum源
  13. ORACLE_11G归档空间满,由于数据库装完后使用的是默认空间是闪回区
  14. SpringCloud+Feign环境下文件上传与form-data同时存在的解决办法
  15. 第一节 简单的jsp实例
  16. Kubernetes 安装
  17. 深入 JSX
  18. Android -- 文件扫描
  19. Cognos 报表在列表上面显示汇总
  20. 051——VUE中自定义指令:directive

热门文章

  1. linux获取本机ip
  2. Permission denied:multiarray.cp35-win_amd64.pyd(tensorflow0.12.0在windows下安装)
  3. IndexedDB参考资料网址
  4. 使用SerialPort 读取外置GPS信息和使用GeoCoordinateWatcher获取内置gps的信息
  5. python的类与对象
  6. Jquery Mobile示例
  7. freemarker
  8. codeforces 742D Arpa's weak amphitheater and Mehrdad's valuable Hoses ——(01背包变形)
  9. Oracle中的sql操作符 和分析函数
  10. C语言学习笔记(二)_system系统调用及posix说明