linux - make file编译两个C程序文件

标签 linux unix makefile g++

我有两个名为 client.c 和 server.c 的 C 程序文件。这两个都包含主要功能。我在使用 g++ 和 makefile 编译它们时遇到了麻烦。

all:
    g++ client.c server.c -o client server.c

最佳答案

我已经弄清楚了,因为这是两个不同的文件,所以它们应该像这样单独编译。

all: client server

client:
       g++ -o client client.c

server:
       g++ -o server server.c

关于linux - make file编译两个C程序文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39789099/

相关文章:

linux - 回显 "foo"| sudo tee -a 幂等

linux - 如何在 vi 编辑器中一次搜索 3 个字符串?

Java:将无符号 8 字节时间戳转换为微秒精确日期

makefile - 如何将目标文件放置在单独的子目录中

c - Ubuntu 15.10(内核 4.2): Hello world kernel module makefile error

linux - 链接目录中的文件,使用类似于 cp 的简单命令

linux - 如何在任何 linux 发行版中找到 python 包名称?

c - 如何从 C 程序构建用于 Unix system() 调用的字符串

linux - 将unix/linux文件名字符集转换为windows

c - Makefile 依赖被忽略