zoukankan      html  css  js  c++  java
  • GNU project C

    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
  • 相关阅读:
    Read-Copy Update Implementation For Non-Cache-Coherent Systems
    10 华电内部文档搜索系统 search04
    10 华电内部文档搜索系统 search05
    lucene4
    10 华电内部文档搜索系统 search01
    01 lucene基础 北风网项目培训 Lucene实践课程 索引
    01 lucene基础 北风网项目培训 Lucene实践课程 系统架构
    01 lucene基础 北风网项目培训 Lucene实践课程 Lucene概述
    第五章 大数据平台与技术 第13讲 NoSQL数据库
    第五章 大数据平台与技术 第12讲 大数据处理平台Spark
  • 原文地址:https://www.cnblogs.com/unixshell/p/3453535.html
Copyright © 2011-2022 走看看