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
One of frequent mistakes might be typo in another file name.
You example is quite straightforward but what may sometimes confuse are messages of
make
itself. Lets consider an example.My folder contents is:
Whereas my
makefile
looks likeAlthough I do have
index.md
where it should be and there is no mistake in the name of it, the message frommake
will beTo be honest the message is utterly wrong. Lets alter
makefile
a little, which is to say replace patterns with explicit rules:And now the message we get will be:
Miracle! The following might be concluded:
Messages of
make
depends on rules and does not always point to the root of problemsThere might be other problems in your
makefile
different from specified by this messageNow we've come up with the idea of checking other dependencies in a rule as well:
Only this will provide us with the desired result:
I got the same error when I only copy the Source directory to different location.
It was solved after I moved the Build directory too.
In my experience, this error is frequently caused by a spelling error.
I got this error today.
In my case the error was simply a spelling error. The word MAINTENANCE was missing it's third N.
Also check the spelling on your filenames.
In my case it was due to a multi-line rule error in the Makefile. I had something like:
The backslash at the end of file list in
CONFIG_OBJ1
's rule caused this error. It should be like:In my case, it was due to me calling the Makefile: MAKEFILE (all caps)
That's usually because you don't have a file called
vertex.cpp
available to make. Check that:Other than that, I've not much else to suggest. Perhaps you could give us a directory listing of that directory.