gpt4 book ai didi

c - 如何制作makefile?

转载 作者:行者123 更新时间:2023-11-30 20:59:41 24 4
gpt4 key购买 nike

我正在尝试为一个项目生成一个简单的 makefile,但遇到了麻烦,因为我仍在适应它们。

我有一个文件夹,其中包含 3 个单独的文件,头文件 LinkedListAPI.h , LinkedListAPI.cStructListDemo.c

必须使用标志:

-Wall -std=c11 

最佳答案

这个看起来不错,但请记住用制表符替换所有缩进:

.PHONY: all clean
CFLAGS:=$(CFLAGS) -std=c11 -Wall
OBJ=./src
INCLUDE=./include
objStringListDemo=$(OBJ)/LinkedListAPI.o $(OBJ)/StringListDemo.o
objStructListDemo=$(OBJ)/LinkedListAPI.o $(OBJ)/StructListDemo.o

all: StringListDemo StructListDemo

StringListDemo: $(objStringListDemo) $(INCLUDE)/LinkedListAPI.h
${CC} -o $< $@

StructListDemo: $(objStructListDemo) $(INCLUDE)/LinkedListAPI.h
${CC} -o $< $@

%.o: %.c
${CC} $(CFLAGS) $< -o $@

clean:
rm -rf $(objStringListDemo) $(objStructListDemo) StringListDemo StructListDemo

关于c - 如何制作makefile?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46171465/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com