我通过以下方式找到了源。
/src/main.cpp
/src/hearts/hearts.cpp
/src/spades/spades.cpp
/src/oldmaid/oldmaid.cpp
我将如何为此创建一个 makefile?
最佳答案
我的 Makefile 的摘录。这会在 src 目录中搜索 cpp 文件并编译它们。您可以添加新文件并自动选择它们。
CC = g++
all: compile
find src -name '*.o' -print0 | xargs -0 $(CC) -o myExecutable
compile:
find src -name '*.cpp' -print0 | xargs -0 $(CC) -c
clean:
find src -iname '*.o' -print0 | xargs -0 rm
关于c++ - 如何在子目录中生成带有源代码的 Makefile?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13597051/