• 关于makefile的编写


    这两天学了Makefile,下面记录一些有关与自己的学习笔记.
    make 命令执行时,需要一个 Makefile 文件,以告诉 make 命令需要怎么样的去编译和链接程序.
    #####一.基本语法
    1.首先,我们看下makefile书写规则:

    target : preprequisites 
    command(注意,此行一定是开头tab键然后才开始写命令)
    

    2.makefile当中#代表注释 

    3.最后一行可写 

    clean: 
    rm -f *o 
    #清除以构建的目标文件

    二.实例:
    首先我的程序是创建一个People类,然后再创建 Student类和Teacher类共有继承People类,在Student类中创建一个私有属性Teacher类的对象teacher,最后在main函数里创建Student类的对象student.
    函数编译过程是先编译people.cpp,然后创建student时会先创建t eacher对象,因此要先编译teacher.cpp再编译student.cpp,最后再编译
    main.cpp,大致过程就是如此,
    makefile代码如下:

    main:main.cpp student.o people.o teacher.o
        g++ main.cpp student.o people.o teacher.o -o main
    student.o:student.h people.o
        g++ student.cpp -c -o student.o
    teacher.o:teacher.h people.o
        g++ teacher.cpp -c -o teacher.o
    people.o:people.h
        g++ people.cpp -c -o people.o
    clean:
        rm -f *o
    

      

     
  • 相关阅读:
    乘法逆元
    P1082 同余方程
    数论编程
    倍增LCA模板
    快速幂模板Super
    黑白染色的模板
    暑假提高组集训Day1 T2
    暑假提高组集训Day1 T1
    7月18日刷题记录 二分答案跳石头游戏Getting
    hdu4738(割桥)
  • 原文地址:https://www.cnblogs.com/topk/p/6580125.html
Copyright © 2020-2023  润新知