2013-06-28 215 views
1

我剛開始學習C難題,我在練習#2。學習C難題練習2

鏈接在這裏: http://c.learncodethehardway.org/book/ex2.html

的指令,以使文件只用這它:

CFLAGS=-Wall -g 

    clean: 
     rm -f ex1 

所以我創建並保存,作爲Makefile.c,然而,一旦運行它作爲在我的編譯器(MINGW)規定,我得到這個錯誤:

$make clean 
cc makefile.c -o makefile 
makefile.c:3:1: warning: data definition has no type or storage class [enabled by default] 
makefile.c:3:9: error: 'Wall' undeclared here (not in a function) 
makefile.c:3:15: error: 'g' undeclared here (not in a function) 
makefile.c:5:1: error expected ',' or ';' before 'clean' 
cc Makefile.c -o Makefile 
Makefile.c:3:1: warning: data definition has no type or storage class [enabled by default] 
Makefile.c:3:9: error: 'Wall' undeclared here (not in a function) 
Makefile.c:3:15: error: 'g' undeclared here (not in a function) 
Makefile.c:5:1: error expected ',' or ';' before 'clean' 
make: *** No rule to make target 'clean'. Stop. 

任何想法,我做錯了什麼和/或如何,我可以解決這個問題?謝謝!

回答

0

您是否使用製表符而不是空格?該網頁有空格,但是makefile需要選項卡。注意makefile代碼之後的作者評論。

3

晚了,但你的makefile應該只是被命名爲「Makefile的」

的Makefile不是一個C程序的源代碼,而是一組爲使Makefile工具,它被用來說明當你鍵入「使富」。

1

Makefile文件可以被稱爲 「makefile文件」 或 「生成文件」

據男子化妝:

"Normally you should call your makefile either makefile or Makefile. (We recommend Makefile because it appears prominently near the beginning of a directory listing, right near other important files such as README.) The first name checked, GNUmakefile, is not recommended for most makefiles."