【问题标题】:Make file to compile two C program filesmake file 编译两个C程序文件
【发布时间】:2016-09-30 10:14:15
【问题描述】:

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

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

【问题讨论】:

  • 您需要为每个程序创建两个编译目标。您现在将尝试构建一个名为“client”的输出二进制文件,将两者合并。

标签: linux unix makefile g++


【解决方案1】:

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

all: client server

client:
       g++ -o client client.c

server:
       g++ -o server server.c

【讨论】:

    猜你喜欢
    • 2021-11-23
    • 1970-01-01
    • 2011-02-05
    • 1970-01-01
    • 1970-01-01
    • 2014-04-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多