zoukankan      html  css  js  c++  java
  • make file 和 GCC标志学习

    GCC:

    -Wall : 打开警告标志

    -std=standard : -ansi 相等 -std=c89

    -ansi : 指定代码应该符合什么标准。

    -c : Compile and assemble, but do not link.

    [-Dmacro[=defn]...] : 定义宏

    -S gcc -S sum.c -o sum.s 要求 gcc 產生組合語言程式碼
    -E gcc -E hello.c -o hello.i 只執行巨集展開, 但不產生目的檔
    -D gcc -DDEBUG sum.c -o sum 定義 #define DEBUG 後才編譯
    -g gcc -g sum.c -o sum 編譯時加入除錯資訊, 讓 gdb 可遠端除錯
    -c gcc -c hello.c -o hello.o 編譯並組譯程式碼, 但不做連結
    -I gcc -c -I /home/ccc/include -o hello.o hello.c 指定引用檔 (*.h) 的路徑
    -L gcc -L /home/ccc/lib -o hello hello.o 指定函式庫 (*.a) 的路徑
    -l gcc -L /home/ccc/lib -lm -lpthread -o hello hello.o 指定函式庫的名稱
    -shared gcc -shared a.o b.o c.o -o libabc.so 產生共享函式庫 (*.so)
    -fPIC gcc -g -rdynamic -fPIC -o test test.c 輸出 position-independent code, 一般在輸出動態連結函式庫時使用
    -Werror gcc -Werror sum.c -o sum.s 將警告視為錯誤, 一旦有警告就不輸出目標檔
    -O0 gcc -S -O0 sum.c -o sum.s 不進行最佳化 (預設)
    -O1 gcc -S -O1 sum.c -o sum.s 第 1 級的最佳化 (較差)
    -O2 gcc -S -O2 sum.c -o sum.s 第 2 級的最佳化
    -O3 gcc -S -O3 sum.c -o sum.s 第 3 級的最佳化 (最高等級)
    -dr gcc -c -dr sum.c -o sum.o 輸出 RTL 中間碼

    make file:

    https://www.gnu.org/software/make/manual/html_node/Automatic-Variables.html

    % 萬用字元、$@ 特殊符號、.PHONY 假目標

    $@ 代表工作目標. The file name of the target of the rule. 

    $^ 代表所有的必要條件

    $< 代表第一個必要條件. The name of the first prerequisite. 

    $? The names of all the prerequisites that are newer than the target, with spaces between them. 

    $% The target member name, when the target is an archive member. 

    从1文件夹里面的makefile开始,

    然后包含了$(ROOT)/Make.defines.$(PLATFORM)这个平台的makefile,他里面主要定义了:根据这个例子,理解APUE的编译,那就是

    CC是编译器,COMPILE.c是编译器.c文件的选项,LINK.c是链接.c文件的编译选项,LDFLAGS是库文件夹的位置,LDLIBS是外部库的所有对象(EXTRALIBS没看到定义),CFLAGS是编译的标志

    然后在1的makefile中,定义了,如何编译这个程序。

    最后包含$(ROOT)/Make.libapue.inc这个makefile文件,在这个文件里面,是进入lib这个文件夹,并且进行编译,

    在$(ROOT)/lib的makefile文件里面,进行了下面的工作, 在这里面,进行了真正的编译静态库的工作。


    AR的参数:

    http://blog.csdn.net/zougangx/article/details/3073604

    http://www.voidcn.com/blog/yangruibao/article/p-635550.html

    -r  将文件插入备存文件中。

    v  程序执行时显示详细的信息。 

  • 相关阅读:
    生成器和推导式
    闭包
    python
    python初识函数二
    python函数初识
    python文件操作二
    文件操作
    python集合,深浅copy
    Python安装、配置图文详解
    jsDoc 使用及配置!
  • 原文地址:https://www.cnblogs.com/hwy89289709/p/6848255.html
Copyright © 2011-2022 走看看