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. 【原创】javascript——事件思维导图

  2. VS编辑代码的时候,都会自动在资源浏览器里将文件所在项目展开

    如何设置VS编辑代码的时候,都会自动在资源浏览器里将文件所在项目展开 工具-选项-项目和解决方案-常规-在解决方案资源管理器中跟踪活动项(C)

  3. POJ3723 Conscription

    http://poj.org/problem?id=3723 这题虽然简单,但是还是错了很多次. 因为这题构建的图可能是不连通的.也就是说可能有很多棵树. 所以我以前写的并查集用在这上面会出问题的. ...

  4. ZEDBOARD启动自启配置(加载镜像) 分类: OpenCV ubuntu shell ZedBoard Eye_Detection 2014-11-08 18:53 167人阅读 评论(0) 收藏

    参考:陆书14.2.8 1)备份ramdisk8M.image.gz 2)加载rootfs镜像文件: 3)在镜像目录下建立自己所需文件夹(挂载目录): 我需要的挂载目录有两个: root/qt/ins ...

  5. 关于MySQL的各种总结

    https://blog.atime.me/note/mysql-summary.html 总结使用MySQL过程中遇到的各种问题和一些有用的资源,配置等等.将之前的若干篇零散的文章汇总到一起,备忘. ...

  6. systemtap [主设备号,次设备好,inode]监控文件

    SystemTap 是监控和跟踪运行中的linux 内核的操作的动态方法,SystemTap 应用:对管理员,SystemTap可用于监控系统性能,找出系统瓶颈,而对于开发者,可以查看他们的程序运行时 ...

  7. 亲测PHP环境

    一.安装Apache2.2.22→1.下载软件,点安装 2.填写dengguoxing.com  www.dengguoxing.com(暂时不知道什么用)3.custom 个性化安装 更改路径即可 ...

  8. HTML select 操作

    今天遇到一个问题,就是想设置select的默认选择项.但是试了很多方法都不行: <fieldset data-role="contractstatus"> <la ...

  9. codevs 1519 过路费 最小生成树+倍增

    /*codevs 1519 过路费 最小生成树+倍增*/ #include<iostream> #include<cstdio> #include<cstring> ...

  10. css3 calc()

    概述 CSS函数calc()可以用在任何一个需要<length>的地方.有了calc(),你可以通过计算来决定一个对象的大小和形状. 你还可以在一个calc()内部嵌套另一个calc(). ...