简体   繁体   中英

How to deal with Makefile error: make: *** [Makefile:11: test] Error 3

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

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 ./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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM