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

后端 未结 3 645
陌清茗
陌清茗 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:11

    All you need to do is tell make that the .o file depends on the .cpp file:

    %.cpp.o: %.cpp
        g++ -Wall -c -o $@ $<
    

提交回复
热议问题