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

GNU project C的更多相关文章

  1. GNU M4 - GNU Project - 免费软件基金会(FSF)

    -------------------------------------------------------------------------------------- GNU M4介绍: GNU ...

  2. 编译GNU Global

    GNU Global是一套界面更友好的tag系统,但是因为其支持的语言太少,现在一般使用其为前端,后端一般使用最新的Universal Ctags. 编译办法如下: 1.去GNU Project ht ...

  3. 6、GNU makefile工程管理学习的一个例子

    在之前我们已经学习了一个文件的编译过程,但是做过项目的都知道,一个工程中的源文件不计其数,其按类型.功能.模块会分别放在若干个目录中,而这些文件如何编译就需要有一个编译规则,虽然现在很多大型的项目都是 ...

  4. 【转】简说GNU, GCC and MinGW (Lu Hongling)

    原地址:https://my.oschina.net/u/588967/blog/73478 GNU, GCC, MinGW是开源社区常常要遇到的概念. 网上一般的解释比较繁琐, 让人如坠云雾. 本文 ...

  5. MinGW ,GNU 是什么

    MinGW : Minimalist GNU for Windows MinGW(Minimalist GNU For Windows)是个精简的Windows平台下的 C/C++.ADA及Fortr ...

  6. [转帖]GNU, Free Software and Open Source 自由软件与开源软件

    GNU, Free Software and Open Source 自由软件与开源软件 https://blog.csdn.net/icycolawater/article/details/7792 ...

  7. Beginning Linux Programming 学习--chapter 1 Getting start--What's linux,GNU,HeaderFiles, Libraries

    "文明的建立的不是机器而是思想" -- 托尔斯泰 Linux truly become a viable operating system, especially in the s ...

  8. Shell脚本编程30分钟入门

    Shell脚本编程30分钟入门 转载地址: Shell脚本编程30分钟入门 什么是Shell脚本 示例 看个例子吧: #!/bin/sh cd ~ mkdir shell_tut cd shell_t ...

  9. OpenCASCADE DataExchange DWG

    OpenCASCADE DataExchange DWG eryar@163.com Abstract. DWG is a file format created in the 70’s for th ...

随机推荐

  1. (三)phpcms之文件目录

    刚刚接触phpcms,先从它的目录结构说起. 如下图所示,是phpcms的主目录结构: 其中api是接口目录,这个接口不是很明白.大概其是把别的内容加入进来,比如论坛啊什么的. caches是缓存文件 ...

  2. C标签

    关键字:JSTL标签.<c:choose>.<c:forEach>.<c:forTokens>.<c:if>.<c:import>.< ...

  3. Java keyword具体解释

    訪问控制修饰符号 1)        private 私有的 private keyword是訪问控制修饰符,能够应用于类.方法或字段(在类中声明的变量). 仅仅能在声明 private(内部)类.方 ...

  4. Spark1.0.0 监测方法

          Spark1.0.0能够通过下面几种方式来对Spark应用程序进行监控: Spark应用程序的WebUI或者Spark Standalone的集群监控 指标,然后通过支持指标收集的集群监控 ...

  5. 计算机体系结构-CPU

    NUMA

  6. Java语言基础(二)

    Java语言基础(二) 一.变量续 (1).变量有明确的类型 (2).变量必须有声明,初始化以后才能使用 (3).变量有作用域,离开作用域后自动回收 变量作用域在块内有效 (4).在同一定义域中变量不 ...

  7. Java多线程之释放对象的锁

          由于等待一个锁定线程只有在获得这把锁之后,才能恢复运行,所以让持有锁的线程在不需要锁的时候及时释放锁是很重要的.在以下情况下,持有锁的线程会释放锁: 1. 执行完同步代码块. 2. 在执行 ...

  8. linux设置语言编码

    前段时间在服务器上安装了centos6.2版本,当初安装时语言选择英文.这本来也没有什么问题,直到前一段时间.我的同事发现部署的web项目中出现乱码情况.但中文作为参数进行传递到下一个页面的时候就乱码 ...

  9. Java异常之try,catch,finally,throw,throws

    Java异常之try,catch,finally,throw,throws 你能区分异常和错误吗? 我们每天上班,正常情况下可能30分钟就能到达.但是由于车多,人多,道路拥挤,致使我们要花费更多地时间 ...

  10. TextView使用Spannable设置复合文本

    http://blog.csdn.net/linghu_java/article/details/32053167 Spannable 对文字的编辑减少TextView的拼接并且达到改变一串字符中的部 ...