zoukankan      html  css  js  c++  java
  • makefile--回顾基础篇

    前阵子让写makefile,纠结了下,基本忘记差不多了。

    1.gcc的编译选项

    -c

    只是编译不链接,生成目标文件“.o”

    -S

    只是编译不汇编,生成汇编代码

    -E

    只进行预编译,不做其他处理

    -g

    在可执行程序中包含标准调试信息

    -o file

    把输出文件输出到file里

    -v

    打印出编译器内部编译各过程的命令行信息和编译器的版本

    -I dir

    在头文件的搜索路径列表中添加dir目录

    -L dir

    在库文件的搜索路径列表中添加dir目录

    -static

    链接静态库

    -llibrary

    连接名为library的库文件

    2.makefile的规则

    target...: prerequire...

      command

    看到这个就熟悉了

    3. makefile的文件中有什么

    a)依赖的部分include

    b)变量定义

    c)显示规则(你所直观看到的依赖)

    d)隐式规则(偷懒依靠makefile语法省写的那部分)

    e)注释#

    4.makefile 的工作步骤:

    a)读取makefile

    b)读include

    c)初始化文件中的变量

    d)推导隐式规则

    e)为所有目标建立依赖链

    f)根据依赖链,决定生成哪些目标

    g) 执行生成命令

    5.最简单的demo

    target=hello
    target_o=hello.o
    target_c=hello.c

    $(target):$(target_o)
            cc  -o $(target) $(target_o)
    $(target_o):$(target_c)
            cc -c $(target) $(target_c)

  • 相关阅读:
    webkit 技术内幕 笔记 二
    webkit 技术内幕 笔记 一
    javascript 权威指南1
    正则
    react-virtualized
    移动端字体
    vue 学习3
    vue 学习2
    vue 学习1
    移动端display:flex
  • 原文地址:https://www.cnblogs.com/ashen/p/8018693.html
Copyright © 2011-2022 走看看