Alright, this is for a school project where I am supposed to complete a skeleton program provided by the professor. Here is the makefile as provided to me:
db: db.o students.o courses.o enrolls.o
cc db.o students.o courses.o enrolls.o -o db
db.o: db.c types.h students.h courses.h enrolls.h db.h
cc -c db.c
students.o: students.c types.h students.h
cc -c students.c
courses.o: courses.c types.h courses.h
cc -c courses.c
enrolls.o: enrolls.c types.h students.h courses.h enrolls.h
cc -c enrolls.c
Now, this worked fine in the commandline (with gcc) and in Dev C++, but when I tried to use Netbeans it threw an error, saying something about the clean command. So, I added this line:
clean:
rm -f *.exe *.o
to the end of the file, and it worked fine (in Netbeans). But, it still won’t work in Eclipse CDT. It gives this error:
Description Resource Path Location Type
make: *** No rule to make target `all'. Stop. Course Project C/C++ Problem
So, I tried adding
all:db
to the top, but then it throws this error:
Description Resource Path Location Type
make: *** [db] Error 1 Course Project C/C++ Problem
So, now I’m at a loss for what to do. I’ve Googled around, but nothing has seemed to work yet. Any ideas on how to change this makefile so it works in Eclipse?
Here is the makefile in its current (non-functional) form:
all:db
db: db.o students.o courses.o enrolls.o
cc db.o students.o courses.o enrolls.o -o db
db.o: db.c types.h students.h courses.h enrolls.h db.h
cc -c db.c
students.o: students.c types.h students.h
cc -c students.c
courses.o: courses.c types.h courses.h
cc -c courses.c
enrolls.o: enrolls.c types.h students.h courses.h enrolls.h
cc -c enrolls.c
clean:
rm -f *.exe *.o
As far as I know, Eclipse use gnu make/gcc as a default build toolchain. So if your makefile works in a shell it should work in Eclipse. The first error you mention just points out that Eclipse build with the default command “make all”. Adding ‘all: db’ should have corrected this problem. As @Bug Catcher said you should have a space between ‘all:’ and ‘db’. You can also add a .PHONY statement :