我检查了以前的问题,但没有找到与我的相似的问题:
我有client和server两个进程
首先我在 ubuntu gcc 上执行:
g++ -o a daemon.cpp exclude_fucntion.cpp -lpthread -std=c++11
然后运行 ./a
客户端执行:
g++ -o b user_main.cpp client.cpp
执行 ./b
我可以创建 make 文件以便在执行它时可以创建 bot a
和 b
吗?
或者 makefile 如何对我的案例有用?
我是 makefile 的新手。
最佳答案
除非指定目标,否则 Make 将构建第一个目标。因此,如果使用以下 Makefile 执行 make,实际上 make all 将运行。这要求目标 a 和 b 是最新的,它们在下面指定。 (记得用制表符替换前导空格)
all: a b
a: daemon.cpp exclude_fucntion.cpp
g++ -o a daemon.cpp exclude_fucntion.cpp -lpthread -std=c++11
b: user_main.cpp client.cpp
g++ -o b user_main.cpp client.cpp
关于c++ - 为多次执行创建makefile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19026089/