我试图使用GCC (linux)与makefile编译我的项目。

我得到了以下错误,似乎无法在这种情况下破译:

"No rule to make target 'vertex.cpp', needed by 'vertex.o'.  Stop."

这是生成文件:

a.out: vertex.o edge.o elist.o main.o vlist.o enode.o vnode.o
    g++ vertex.o edge.o elist.o main.o vlist.o enode.o vnode.o

main.o: main.cpp main.h
    g++ -c main.cpp

vertex.o: vertex.cpp vertex.h
    g++ -c vertex.cpp

edge.o: edge.cpp edge.h
    g++ -c num.cpp

vlist.o: vlist.cpp vlist.h
    g++ -c vlist.cpp

elist.o: elist.cpp elist.h
    g++ -c elist.cpp

vnode.o: vnode.cpp vnode.h
    g++ -c vnode.cpp

enode.o: enode.cpp enode.h
    g++ -c node.cpp

当前回答

根据我的经验,这个错误通常是由拼写错误引起的。

我今天收到这个错误。

make[1]: ***没有创建目标maintenaceDialog.cpp'的规则,maintenacedialog .o'需要。停止。

在我的例子中,这个错误只是一个拼写错误。MAINTENANCE这个词缺了第三个N。

还要检查文件名的拼写。

其他回答

这通常是因为您没有一个名为vertex.cpp的文件可用。检查:

该文件存在。 你在正确的目录下。

除此之外,我没有什么建议了。也许你能给我们一份那个目录的目录清单。

在我的情况下,路径没有设置在VPATH,添加后的错误消失了。

当我忘记向我的git存储库添加新文件时,在Travis内部发生了这个错误。愚蠢的错误,但我可以看出这是相当普遍的。

如果你试图构建John the Ripper“bleed -jumbo”,并得到类似“make: *** No rule to make target 'linux-x86-64'”这样的错误。尝试运行以下命令:./configure && make

在我的情况下,这是由于我板条箱文件像MakeFile而不是它应该是MakeFile。