且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

gcc makefile错误:“没有规则做目标......”

更新时间:2022-10-17 10:14:02

这通常是因为你不' t有一个名为 vertex.cpp 的文件可用。请检查:


  • 该文件存在。

  • 在制作时,您位于正确的目录中。


除此之外,我没有其他建议。也许你可以给我们一个该目录的目录列表。


I'm trying to use GCC (linux) with a makefile to compile my project.

I get the following error which is can't seem to decipher in this context:

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

This is the makefile:

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

That's usually because you don't have a file called vertex.cpp available to make. Check that:

  • that file exists.
  • you're in the right directory when you make.

Other than that, I've not much else to suggest. Perhaps you could give us a directory listing of that directory.