Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No targets specified and no makefile found

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?

like image 844
Malloc Avatar asked Feb 10 '11 20:02

Malloc


People also ask

What is the default make target?

By default, the goal is the first target in the makefile (not counting targets that start with a period). Therefore, makefiles are usually written so that the first target is for compiling the entire program or programs they describe.

How make install works?

make follows the instructions of the Makefile and converts source code into binary for the computer to read. make install installs the program by copying the binaries into the correct places as defined by ./configure and the Makefile. Some Makefiles do extra cleaning and compiling in this step.


2 Answers

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.

like image 78
bbum Avatar answered Nov 15 '22 09:11

bbum


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.

like image 22
JeremyP Avatar answered Nov 15 '22 08:11

JeremyP