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. poj2406--Power Strings(KMP求最小循环节)

    Power Strings Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 33178   Accepted: 13792 D ...

  2. 《大话操作系统——做坚实的project实践派》(6)

     继续写硬件体系.这个不写完.不会写操作系统内核.由于根基不正,则难于达到上层境地.

  3. HTML及简单标签介绍

    什么是HTML: HTML 语言是一种超文本的标记语言,简单来讲就是构建一套标记符号和语法规则,将所要显示出来的文字.图象.声音等要素按照一定的标准要求排放,形成一定的标题.段落.列表等单元. 标签 ...

  4. cocoaPods下载使用记录

    cocoaPods下载使用记录 参考地址: 如何在Mac OS 上安装运行Ruby运行环境 http://www.cnblogs.com/daguo/p/4097263.html cocoaPods安 ...

  5. jad批量反编译class和jadeclipse集成到eclipse的设置方法

    安装jad配置 1.从http://varaneckas.com/jad/下载windows版本的jad.exe 2.安装完毕后配置jad的系统环境变量 批量解压jar和class文件 1.使用7zi ...

  6. 常用的 css 命名规则

    头:header 内容:content/container 尾:footer 导航:nav 侧栏:sidebar 栏目:column 页面外围控制整体布局宽度:wrapper 左右中:left rig ...

  7. (转)resize扩展

    jquery 默认的resize只能监听到浏览器窗口大小的改变,但我们在实际使用过程中有可能还需要监听某个div或其它标签的大小改变来执行相应的处理,如果使用默认的resize就无能为力了.怎么办呢, ...

  8. WCF,WebAPI,WCFREST和WebService的区别

    Web ServiceIt is based on SOAP and return data in XML form.It support only HTTP protocol.It is not o ...

  9. java web(jsp)-The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path

    在静态项目上新建 jsp文件的时候,报错:The superclass "javax.servlet.http.HttpServlet" was not found on the ...

  10. 关于C#与.NET Framework

    前几天,有一个做测试的问我.NET Framework是什么,和C#是什么关系呢. 下面我就来解释一下.NET Framework是什么:.NET Framework是一个框架,是应用程序运行时所需要 ...