gpt4 book ai didi

使用 CL 编译多个文件

转载 作者:太空宇宙 更新时间:2023-11-04 03:40:34 26 4
gpt4 key购买 nike

这个 GNU makefile 如何查找 windows(我必须使用 nmake 和 CL):

CC = gcc
CFLAGS = -Wall -Wextra -g

build: main

main: utils.o bucket.o hashset.o main.o

utils.o: utils.c utils.h

bucket.o: bucket.c bucket.h

hashset.o: hashset.c hashset.h

main.o: main.c

.PHONY:
clean:
rm -f *.o *~ main

我能想到的就是这个:

CPP = cl
CFLAGS = /nologo /W4 /EHsc /Za

build : main

main: utils.obj bucket.obj hashset.obj main.obj
$(CPP) $(CFLAGS) /Fe$@ $**

utils.obj: utils.c
$(CPP) $(CFLAGS) /Fo$@ $**

bucket.obj: bucket.c
$(CPP) $(CFLAGS) /Fo$@ $**

hashset.obj: hashset.c
$(CPP) $(CFLAGS) /Fo$@ $**

main.obj: main.c
$(CPP) $(CFLAGS) /Fo$@ $**

clean:
del *.obj main

请注意,我的作业是实现一个哈希集,我已经完成了,现在只是 makefile 困扰着我。我不断收到每个文件的错误:文件意外结束

最佳答案

感谢您的帮助,同时我自己想出了答案:

CPP = cl
OBJ_LIST = main.obj utils.obj bucket.obj hashset.obj

build: main

main: $(OBJ_LIST)
$(CPP) /Fe$@ $**

clean:
del *.obj main.exe

关于使用 CL 编译多个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29041875/

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