gpt4 book ai didi

makefile - make : *** No rule to make target all'. 停止

转载 作者:行者123 更新时间:2023-12-01 23:39:36 26 4
gpt4 key购买 nike

一段时间以来,我一直在尝试制作正确的 makefile,但我不断收到错误消息“make:*** 没有规则可以制作目标‘全部’。停止。”

我有一个主程序:mpasswdsort.c
和 mpasswdsort 使用的 c 文件,它也带有一个标题:
list.c 和 list.h

我的生成文件:

CC=gcc
CFLAGS=-Wall -pedantic -ansi
all: mpasswdsort
server: mpasswdsort.o list.o
$(CC) mpasswdsort.o list.o -o mpasswdsort
mpasswdsort.o: mpasswdsort.cpp
$(CC) $(CFLAGS) mpasswdsort.cpp
list.o: list.cpp
$(CC) $(CFLAGS) list.cpp
clean:
rm -f server client *.o core

我不确定它是否在 makefile 中出错,或者 makefil 是否不应该是 .txt 文件。

最佳答案

您提供的错误消息表明 make没有看到任何构建目标“all”的规则。与 GNU make 的诊断完全相同当根本没有 makefile 时发出。由于您提供的 makefile 内容确实包含目标“all”的规则,我得出的结论是 make没有看到他们。

这可能是因为 makefile 位于不同的目录中,因为它的名称与 make 的名称不同。默认情况下会尝试( Makefilemakefile 是常规的;GNU 版本的 make 也会检查 GNUmakefile ),或者因为访问控制问题阻止了 make从读取文件。既然你评论了

I am unsure if its wrong in the makefile or if the makefil isnt supposed to be a .txt file.



,最可能的结论是(至少)文件名是错误的。 Makefile 是文本文件,但文本文件名不一定以“.txt”结尾。事实上,在 Linux 和其他 UNIX 上,它们中的大多数都没有。 Makefile 不应该有这样的扩展名,但是,从技术上讲,您可以使用 -f选项告诉 make要使用的 makefile 的名称。

关于makefile - make : *** No rule to make target all'. 停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46122404/

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