Issue
I'm trying to build a Makefile for my code and for some reason I'm getting
./ex2_q1 11 24 36 7 5
There were 3 prime numbers
make: *** [Makefile:11: test] Error 3
The second line is the output of the program. Everything seems to work Ok but I don't know why I'm getting the error.
the Makefile is:
PROG = ex2_q1
all: test
test: ex2_q1
./ex2_q1 11 24 36 7 5
factors.o: factors.c
gcc -Wall -c factors.c
ex2_q1.o: ex2_q1.c
gcc -Wall -c ex2_q1.c
clean:
rm -vf *.o $(PROG)
rm -vf *.o factors
rm -vf *.txt
rm -vf *.log
factors: factors.o
gcc -o factors -Wall factors.o
ex2_q1: ex2_q1.o factors
gcc -o ex2_q1 -Wall ex2_q1.o
Solution
Your program, ex2_q1
invoked as ./ex2_q1 11 24 36 7 5
returns a non-zero result. This signifies an error and the proper way to address that is to fix your program. If you cannot fix the program you can silence the error by changing the recipe to ./ex2_q1 11 24 36 7 5 || true
. If you still want the error message but continue the build you can run make with -k
flag, or you can prefix the recipe with a -
:
test: ex2_q1
- ./ex2_q1 11 24 36 7 5
Answered By - Allan Wind