"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.omain.o: main.cpp main.h g++ -c main.cppvertex.o: vertex.cpp vertex.h g++ -c vertex.cppedge.o: edge.cpp edge.h g++ -c num.cppvlist.o: vlist.cpp vlist.h g++ -c vlist.cppelist.o: elist.cpp elist.h g++ -c elist.cppvnode.o: vnode.cpp vnode.h g++ -c vnode.cppenode.o: enode.cpp enode.h g++ -c node.cpp
gcc makefile
Share
Improve this question
Follow
edited Jun 18 "15 at 18:25

*

user
5,01977 gold badges4444 silver badges6161 bronze badges
asked May 7 "09 at 13:49
*

MeirMeir
11.1k1919 gold badges5656 silver badges7070 bronze badges
1
Add a comment |

18 Answers 18


Active Oldest Votes
490
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.

You are watching: Make: *** no rule to make target

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


Share
Improve this answer
Follow
answered May 7 "09 at 13:53
*

paxdiablopaxdiablo
791k216216 gold badges15031503 silver badges18631863 bronze badges
5
Add a comment |
87
In my experience, this error is frequently caused by a spelling error.

I got this error today.

make<1>: *** No rule to make target maintenaceDialog.cpp", needed bymaintenaceDialog.o". Stop.

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.


Share
Improve this answer
Follow
edited Sep 13 "17 at 3:22
answered Apr 23 "12 at 14:36
*

WesWes
4,44366 gold badges4141 silver badges5353 bronze badges
2
Add a comment |
33
The more common reason for this message to be printed is because you forgot to include the directory in which the source file resides. As a result, gcc "thinks" this file does not exist.

You can add the directory using the -I argument to gcc.


Share
Improve this answer
Follow
answered Aug 24 "09 at 6:52
Beer.From.A.Mason.JarBeer.From.A.Mason.Jar
Add a comment |
14
In my case I had bone-headedly used commas as separators. To use your example I did this:

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.oChanging it to the equivalent of

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.ofixed it.


Share
Improve this answer
Follow
answered Jun 24 "12 at 17:17
*

Nick KnowlsonNick Knowlson
6,81566 gold badges4343 silver badges6363 bronze badges
0
Add a comment |
11
Is that it exactly? Remember that Makefile syntax is whitespace aware and requires tabs to indent commands under actions.


Share
Improve this answer
Follow
answered May 7 "09 at 13:54
workmad3workmad3
24.1k44 gold badges3434 silver badges5656 bronze badges
0
Add a comment |
8
The problem I found was even sillier than what other folks have mentioned.

Our makefiles get passed lists of things to build. Someone added TheOtherLibrary to one of the lists, as shown below.

LIBRARYDIRS = src/LibraryLIBRARYDIRS = src/TheOtherLibraryThey should have done this:

LIBRARYDIRS = src/LibraryLIBRARYDIRS += src/TheOtherLibraryHad they done it the second way, they would not have wiped out the Library build. The plus in += is very important.


Share
Improve this answer
Follow
answered Feb 11 "14 at 19:14
kmortkmort
2,68822 gold badges2929 silver badges5050 bronze badges
Add a comment |
6
In my case it was due to a multi-line rule error in the Makefile. I had something like:

OBJS-$(CONFIG_OBJ1) += file1.o file2.o file3.o file4.o OBJS-$(CONFIG_OBJ2) += file5.o OBJS-$(CONFIG_OBJ3) += file6.o...The backslash at the end of file list in CONFIG_OBJ1"s rule caused this error. It should be like:

OBJS-$(CONFIG_OBJ1) += file1.o file2.o file3.o file4.oOBJS-$(CONFIG_OBJ2) += file5.o...
Share
Improve this answer
Follow
answered Jun 6 "11 at 12:41
uluortauluorta
12311 silver badge88 bronze badges
Add a comment |
5
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:

$ ls -1another_fileindex.mdmakefileWhereas my makefile looks like

all: index.html%.html: %.md wrong_path_to_another_file
echo $
$Although I do have index.md where it should be and there is no mistake in the name of it, the message from make will be

make: *** No rule to make target `index.html", needed by `all". Stop.To be honest the message is confusing. It just says, that there is no rule. In fact, it means that the rule is wrong, but due to wildcard (pattern) rules make cannot determine what exactly caused the issue.

Lets alter makefile a little, which is to say replace patterns with explicit rules:

index.html: index.md wrong_path_to_another_fileAnd now the message we get will be:

make: *** No rule to make target `wrong_path_to_another_file", needed by `index.html". Stop.Miracle! The following might be concluded:

Messages of make depends on rules and does not always point to the root of problems

There might be other problems in your makefile different from specified by this message

Now we"ve come up with the idea of checking other dependencies in a rule as well:

all: index.html%.html: %.md another_file
echo $
$Only this will provide us with the desired result:

$ makeindex.html index.md
Share
Improve this answer
Follow
edited Aug 2 "19 at 15:18
answered Jul 3 "17 at 23:48
Nick RozNick Roz
3,13922 gold badges3131 silver badges5151 bronze badges
0
Add a comment |
3
In my case, the error message referred to an old filename, which did no longer exist because it was renamed. It turned out that the outdated information did not come from the Makefile, but from files in .deps directories.

I ran into this error after copying files from one machine to another. In that process, I assume the timestamps got in an inconsistent state, which confused "make" when running multiple jobs in parallel (similar to this bug report).

Sequential builds with make -j 1 were not affected, but it took me a while to realize because I was using an alias (make -j 8).

To clean up the state, I removed all .deps files and regenerated the Makefile. These are the commands that I used:

find | grep ".deps" | xargs rmfind | grep ".deps" | xargs rmdirautoreconf --install # (optional, but my project is using autotools) ./configureAfter that, building worked again.


Share
Improve this answer
Follow
answered Dec 24 "17 at 17:35
Philipp ClaßenPhilipp Claßen
34.9k2222 gold badges132132 silver badges211211 bronze badges
0
Add a comment |
2
If you are trying to build John the Ripper "bleeding-jumbo" and get an error like "make: *** No rule to make target "linux-x86-64"". Try running this command instead: ./configure && make


Share
Improve this answer
Follow
answered May 1 "15 at 18:22
OgglasOgglas
43.3k2323 gold badges234234 silver badges292292 bronze badges
Add a comment |
0
In my case, the source and/or old object file(s) were locked (read-only) by a semi-crashed IDE or from a backup cloud service that stopped working properly. Restarting all programs and services that were associated with the folder structure solved the problem.


Share
Improve this answer
Follow
answered Jun 2 "16 at 19:57
sskoogsskoog
4355 bronze badges
Add a comment |
0
Another example of a weird problem and its solution:

This:

target_link_libraries( $PROJECT_NAME $Poco_LIBRARIES $Poco_Foundation_LIBRARY $Poco_Net_LIBRARY $Poco_Util_LIBRARY )gives: make<3>: *** No rule to make target "/usr/lib/libPocoFoundationd.so", needed by "../hello_poco/bin/mac/HelloPoco". Stop.

But if I remove Poco_LIBRARIES it works:

target_link_libraries( $PROJECT_NAME $Poco_Foundation_LIBRARY $Poco_Net_LIBRARY $Poco_Util_LIBRARY )I"m using clang8 on Mac and clang 3.9 on LinuxThe problem only occurs on Linux but works on Mac!

I forgot to mention: Poco_LIBRARIES was wrong - it was not set by cmake/find_package!


Share
Improve this answer
Follow
answered Dec 31 "16 at 0:05
Mike MittererMike Mitterer
5,60033 gold badges3636 silver badges5151 bronze badges
Add a comment |
0
In my case the path is not set in VPATH, after added the error gone.


Share
Improve this answer
Follow
answered Jan 8 "18 at 10:24
tzuhsuntzuhsun
6166 bronze badges
Add a comment |
0
There are multiple reasons for this error.

One of the reason where i encountered this error is while building for linux and windows.

I have a filename with caps BaseClass.h SubClass.hUnix maintains has case-sensitive filenaming convention and windows is case-insensitive.

C++ why people don't use uppercase in name of header files?

Try compiling clean build using gmake clean if you are using gmake

Some text editors has default settings to ignore case-sensitive filenames. This could also lead to the same error.

how to add a c++ file in Qt Creator whose name starts with capital letters ? It automatically makes it small letter


Share
Improve this answer
Follow
answered May 17 "18 at 15:42
corningcorning
16311 silver badge1515 bronze badges
Add a comment |
0
This error occurred for me inside Travis when I forgot to add new files to my git repository. Silly mistake, but I can see it being quite common.


Share
Improve this answer
Follow
answered Sep 26 "18 at 18:22
Ryan DeschampsRyan Deschamps
18622 silver badges1111 bronze badges
Add a comment |
0
This message can mean many things clearly.

In my case it was compiling using multiple threads. One thread needed a dependency that another thread hadn"t finished making, causing an error.

Not all builds are threadsafe, so consider a slow build with one thread if your build passes other tests such as the ones listed above.


Share
Improve this answer
Follow
answered Sep 14 "20 at 20:58
Andres SalasAndres Salas
14399 bronze badges
2
Add a comment |
0
In my case it was due to I crated file like MakeFile instead it should be Makefile.

See more: Zac Brown Band Jiffy Lube Live, Bristow On August 25, 2019, Zac Brown Band Tickets


Share
Improve this answer
Follow
answered Jul 8 at 8:26
DnyaneshDnyanesh
2,05833 gold badges1717 silver badges1515 bronze badges
Add a comment |
-1
In my case, it was due to me calling the Makefile: MAKEFILE (all caps)


Share
Improve this answer
Follow
answered Dec 6 "14 at 21:25
ninjaPixelninjaPixel
5,47333 gold badges3232 silver badges4545 bronze badges
Add a comment |
Highly active question. Earn 10 reputation (not counting the association bonus) in order to answer this question. The reputation requirement helps protect this question from spam and non-answer activity.

Not the answer you're looking for? Browse other questions tagged gcc makefile or ask your own question.


The Overflow Blog
Upcoming Events
Featured on Meta
Linked
17
Why people don't use uppercase in the name of header files in C++?
12
*** No rule to make target 'class.cpp', needed by `build/....x86/class.o` Stop. error in Ubuntu
8
how to add a c++ file in Qt Creator whose name starts with capital letters ? It automatically makes it small letter
7
Netbeans Remote C++ Development "No rule to make target" Error
4
How to run makefile in Cygwin
0
What's missing: make: *** No rule to make target
1
Running Makefile continuously gives `No rule to make target` error
1
make clean results in no target with specific makefile name
0
Compile STASM on mac
1
C++ Makefile Can't Find Files
See more linked questions
Related
1014
What is the difference between g++ and gcc?
2076
What is the purpose the .PHONY in a Makefile?
2222
Why doesn't GCC optimize a*a*a*a*a*a to (a*a*a)*(a*a*a)?
2
Makefile: No rule to make target despite giving target?
0
gcc makefile error: “No rule to make target …”
0
No rule to target in Makefile (GCC Compiler)
0
Makefile fails with error no rule to make target
1
Generic makefile showing no rule to make target error
1
makefile error: “make: *** No rule to make target …”
Hot Network Questions more hot questions
Question feeding
Subscribe to RSS
Question feed To subscribe to this RSS feed, copy and paste this URL into your RSS reader.


lang-c
Stack Overflow
Products
Company
Stack Exchange Network
site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev2021.10.22.40552


Stack Overflow works best with JavaScript enabled
*

Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.