5

I have a make file that contains this code:

all: main.o Etudiant.o
    gcc -lobjc -o program main.o Etudiant.o
main.o:main.m Etudiant.h
    gcc -c main.m
Etudiant.o:Etudiant.m Etudiant.h
    gcc -c Etudiant.m

When I write this in the shell command:

$make

I got this:

make: **** No targets specified and no makefile found. Stop.

How do I fix this?

Matthew Frederick
  • 22,245
  • 10
  • 71
  • 97
Malloc
  • 15,434
  • 34
  • 105
  • 192
  • Are you running the make command in the directory where makefile is ? – Mahesh Feb 10 '11 at 20:47
  • ...and is the makefile named "Makefile" (with a capital M)? – Sebastian Paaske Tørholm Feb 10 '11 at 20:47
  • If instead of typing `make`, what do you get when you type `ls -l`? – Adam Rosenfield Feb 10 '11 at 20:48
  • i got a long list of my subfolders in which there is the Makefile.m file – Malloc Feb 10 '11 at 21:08
  • 3
    Makefile.m?!?! That is nonsense unless you have an objective-c source named `Makefile.m` on purpose. – bbum Feb 10 '11 at 21:44
  • 1
    Make does not know that "Makefile.m" might be a makefile. Try `make -f Makefile.m`. – Beta Feb 11 '11 at 05:24
  • 1
    Possible duplicate of [make \*\*\* no targets specified and no makefile found. stop](https://stackoverflow.com/questions/14412919/make-no-targets-specified-and-no-makefile-found-stop) – tripleee Sep 26 '19 at 06:29
  • @tripleee surely it's the other way around? This question is 2 years __older__ than the "duplicate" that you are looking at. Or am I missing something here? – Frits Sep 26 '19 at 12:40
  • The relative age is a secondary concern, we generally want to collect the best answers in a single question and mark all others as duplicates, and so the amount of work is more important than the age of the individual questions and answers. – tripleee Sep 26 '19 at 12:42

5 Answers5

16

Mmm... makefiles. Whee.

All that whitespace at the beginning of the line. That has to be tabs. Or Make will barf up a really obscure error. Make sure those are tabs and try again.


See the button on the left side of the keyboard labeled "tab". Delete the spaces and hit that once to insert a tab character.


Try make all. IIRC (been a few years since I've had to muck with makefiles) most makes will default to all, but maybe yours isn't.

Extension doesn't matter.


Holy Heck! We are all Extra Dense(@bbum mostly so)!

"no Makefile found" means... well.. that Make didn't even see the makefile. The suggestions to rename the Makefile.m to Makefile are correct. As well, the whole tab vs. whitespace thing is certainly pertinent.

bbum
  • 162,346
  • 23
  • 271
  • 359
  • Hi, the make command in the directory where makefile is and its name is Makefile with M. however what`s "tabs" ? – Malloc Feb 10 '11 at 21:02
  • i tried to remove whitespaces, i got always the same output error :( – Malloc Feb 10 '11 at 21:14
  • 1
    @Malek: And make sure your editor is set to use “real tabs” or “hard tabs”, not spaces. If you're using a Cocoa-based editor such as Xcode, press ctrl-q, then tab to always insert a real tab. – Peter Hosey Feb 10 '11 at 22:04
  • In emacs you can run M-x tabify – dcolish Feb 10 '11 at 22:22
  • i deleted the spaces and replaced it by tabs but the same error, i do not know what to do :( – Malloc Feb 10 '11 at 23:37
  • i tried "make all" command and it said: *** No rule to make target 'all'. Stop – Malloc Feb 11 '11 at 00:38
  • 3
    Bad whitespace would *not* cause "No targets specified and no makefile found". – Beta Feb 11 '11 at 05:21
  • @Beta Herp-d-derp. You are entirely correct and a bunch of us were jumping to problems beyond that. Thanks. – bbum Feb 11 '11 at 08:32
3

and no makefile found

If you just type make with no arguments or make all, make will look for a file called Makefile in the current directory. If it's not there, you get the error you saw. make will not look in subdirectories for Makefile nor will it accept a file called Makefile.m.

JeremyP
  • 84,577
  • 15
  • 123
  • 161
  • 1
    Malek has not specified the version of Make, but GNUMake looks for 'GNUmakefile', then 'makefile', finally 'Makefile'. – Beta Feb 11 '11 at 14:15
1

In my case, the my makefile had the name MakeFile, changing it to Makefile worked

Namya LG
  • 31
  • 5
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 02 '22 at 15:25
0

Re:
$ Make Make: * No targets specified and no makefile found. Stop.

I just had this error and found that the Makefile extension (none) had been converted to .bat somewhere along the line.

vJack
  • 1
0

Just spent a few insanely frustrating moments with this error. My mistake was not all that subtle: I titled the makefile MakeFile not Makefile, so even using the -f Makefile command (forcing the makefile name) still resulted in not-found, because it was MakeFile, not Makefile.