LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   make: *** No rule to make target `main.c', needed by `main.o'. Stop. (https://www.linuxquestions.org/questions/linux-newbie-8/make-%2A%2A%2A-no-rule-to-make-target-%60main-c-needed-by-%60main-o-stop-926408/)

renjith007 01-29-2012 10:28 PM

make: *** No rule to make target `main.c', needed by `main.o'. Stop.
 
I had a doubt regarding Makefile..i have created a Makefile.But i get error like make: *** No rule to make target `main.c', needed by `main.o'. Stop.

My source files main.c,hello.c ,hello1.c resides in src directory and include files function.h function1.h resides in inc directory.These two directories src and inc are in work directory.Make file resides in work directory
---------------------------------------------------
CC=gcc
vpath src
vpath inc

CPPFLAGS=-I inc

main : main.o hello.o hello1.o
$(CC) -o $(CPPFLAGS) $<
..c.o:
main.o : main.c function.h function1.h
$(CC) -c $(CPPFLAGS) $<
hello.o : hello.c function.h
$(CC) -c $(CPPFLAGS) $<
hello1.o : hello1.c function1.h
$(CC) -c $(CPPFLAGS) $<


.PHONY clean:
rm -rf *.o
---------------------------------------------------
can nyone fix this problem plz???

renjith007 01-30-2012 02:41 AM

Got it!!!
 
CC=gcc
vpath src
vpath inc

CPPFLAGS=-I inc

main : main.o hello.o hello1.o
$(CC) -o $(CPPFLAGS) $<

main.o : main.c function.h function1.h
$(CC) -c $(CPPFLAGS) $< $(CPPFLAGS)
hello.o : hello.c function.h
$(CC) -c $(CPPFLAGS) $< $(CPPFLAGS)
hello1.o : hello1.c function1.h
$(CC) -c $(CPPFLAGS) $< $(CPPFLAGS)


.PHONY clean:
rm -rf *.o

changes made in Bold

EDDY1 01-30-2012 03:12 AM

Great job mark thread as solved for others to benefit

rahel 02-07-2012 01:08 AM

I have Almost sme problem, plz I need your help
 
I recently installed AMD APP SDK on linux(ubuntu), so when I tried to compile a sample by the command (make ) as shown in int doc, I got this information:

mkdir -p depends/x86_64
perl ../../../../../make/fastdep.pl -I. -I../../../../../include -I../../../../../samples/opencl/SDKUtil/include --obj-suffix='.o' --obj-prefix='build/debug/x86_64//' BinarySearch.cpp > depends/x86_64/BinarySearch.depend
mkdir -p build/debug/x86_64/
Building build/debug/x86_64//BinarySearch.o
g++ -Wpointer-arith -Wfloat-equal -g3 -ffor-scope -I ../../../../../samples/opencl/SDKUtil/include -I "/include" -I ../../../../../include -o build/debug/x86_64//BinarySearch.o -c BinarySearch.cpp
make: *** No rule to make target `../../../../../samples/opencl/SDKUtil/build/debug/x86_64//libSDKUtil.a', needed by `build/debug/x86_64/BinarySearch'. Stop.


All times are GMT -5. The time now is 07:34 PM.