Reputation: 9
I was wondering if StackOverflow could help me out today! So I am currently finishing up a project in C for one of my CS courses at Uni and I am running into a funny problem. When I use the commands 'make' and 'make test' on my OSX environment it runs just fine, but when I test it on a Ubuntu Virtual Machine, it gives me these errors:
make: prim:Command not found
makefile:32: recipe for target 'test failed.
make: ***[test] Error 127
Here is my makefile code below, any help is appreciated.
OBJS = main.o scanner.o AM.o binheap.o CDLL.o node.o prim.o vertex.o
OPTS = -Wall -Wextra -g -std=c99
main : $(OBJS)
gcc $(OPTS) $(OBJS) -o prim -lm
main.o : main.c scanner.h AM.h binheap.h CDLL.h node.h prim.h vertex.h
gcc $(OPTS) -c main.c
scanner.o : scanner.c scanner.h
gcc $(OPTS) -c scanner.c
node.o : node.c node.h
gcc $(OPTS) -c node.c
AM.o : AM.c AM.h
gcc $(OPTS) -c AM.c
prim.o : prim.c prim.h
gcc $(OPTS) -c prim.c
binheap.o : binheap.c binheap.h
gcc $(OPTS) -c binheap.c
CDLL.o : CDLL.c CDLL.h
gcc $(OPTS) -c CDLL.c
vertex.o : vertex.c vertex.h
gcc $(OPTS) -c vertex.c
test: prim
@echo ###############################
@echo TESTING GRAPH1.TXT
@echo prim graph1.txt
@echo ###############################
prim graph1.txt
@echo ###############################
@echo TESTING GRAPH2.TXT
@echo prim graph2.txt
@echo ###############################
prim graph2.txt
@echo ###############################
clean :
rm -f $(OBJS) main
Upvotes: 0
Views: 438
Reputation: 46992
I think you want to change this:
main : $(OBJS)
gcc $(OPTS) $(OBJS) -o prim -lm
to:
prim : $(OBJS)
gcc $(OPTS) $(OBJS) -o prim -lm
Also, unless prim
is somehow on the path, your shell won't find it. It's probably better to write test rule as:
test: prim
@echo ###############################
@echo TESTING GRAPH1.TXT
@echo prim graph1.txt
@echo ###############################
./prim graph1.txt
@echo ###############################
@echo TESTING GRAPH2.TXT
@echo prim graph2.txt
@echo ###############################
./prim graph2.txt
@echo ###############################
Upvotes: 0
Reputation: 38217
make: prim:Command not found
That error message tells you what's wrong. prim
can't be found in PATH
on Ubuntu. Assuming prim
is the program you just built in the local directory, you should be running ./prim
in your Makefile.
Upvotes: 2