C++: Creating a makefile with two executables? C++

前端 未结 1 1795
故里飘歌
故里飘歌 2021-01-16 16:38

I have two C++ programs that both share a class. progOne.cpp and progTwo.cpp. They both share a class, fileInfo.cpp with the appropriate fileInfo.h file.

This is how

相关标签:
1条回答
  • 2021-01-16 17:33

    You need:

    all: progOne progTwo
    

    This tells make that all depends on progOne and progTwo. If you use all: progOne.cpp ... then if progOne.cpp already exists, make will not need to do anything, and says "nothing to be done for all".

    Of course, next you have to explain to make how progOne and progTwo depend on the source files, so that when you update the source-file, it rebuilds the executable file.

    You may also want to add any header files for progOne.cpp to the dependencies, e.g. progOne: progOne.cpp progOne.h - so that if progOne.h is updated, the program is rebuilt.

    0 讨论(0)
提交回复
热议问题