0
我應該爲我的makefile做些什麼,不僅可以編譯和編譯「test」,而且可以在終端中輸入「make test」時實際運行它,所以我不必每次都做./test ?從makefile運行可執行文件2
LDFLAGS = -lm -L. -lhashi
CFLAGS = -g -Wall -std=c99
SRC=$(wildcard *.c)
OBJETS = $(SRC:.c=.o)
all : prog1 prog2 test
...
test : test_game1.o test_toolbox.o libhashi.a
$(CC) $^ $(LDFLAGS) -o [email protected]
test_game1.o : test_game1.c game.h node.h test_toolbox.h test_game_eliott.c test_game_flo.c test_game_iana.c test_game_remi.c
test_toolbox.o : test_toolbox.c test_toolbox.h
clean :
rm -f ... test_game1.o test_toolbox.o test ...
我剛剛檢查了GNU Make 4.1並且'.phony'不起作用。它必須是'.PHONY'(全部大寫) –
謝謝你的迴應,結果有點奇怪,因爲它運行它,但它說:make:*** [test]錯誤1 – Iana
運行命令(例如「./test」),檢查它的退出狀態。退出狀態不爲0時,表示發生錯誤,並且會報告錯誤。 – FrancoisB