How to define rules in the Makefile to compile only that *.cpp files which was modified (and their dependencies), not all *.cpp files

后端 未结 3 648
陌清茗
陌清茗 2021-02-08 22:56

Lets say I have files:

Libs:

  • one.cpp, one.h
  • two.cpp, two.h
  • three.cpp, three.h

Program:

  • program.cpp
3条回答
  •  忘了有多久
    2021-02-08 23:09

    Add the files a command depends upon to run to the right of the target name.

    Example:

    default: hello.c
       gcc -o hello.bin hello.c
    
    install: hello.bin
       cp hello.bin ../
    

提交回复
热议问题