1

Learn C the Hard Way を始めたばかりで、演習 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.

私が間違っていること、および/またはこれを修正する方法はありますか? ありがとう!

4

3 に答える 3

3

遅くなりましたが、メイクファイルの名前は「Makefile」にする必要があります

Makefile は C プログラムのソース コードではなく、「make foo」と入力すると使用される Makefile ツールの一連の命令です。

于 2013-07-23T03:20:29.170 に答える
1

Makefile は「makefile」または「Makefile」と呼ぶことができます

男のメイクによると:

「通常、makefile は makefile または Makefile と呼ぶ必要があります。(ディレクトリ リストの先頭近く、README などの他の重要なファイルのすぐ近くに目立つように表示されるため、Makefile をお勧めします。)最初にチェックした名前 GNUmakefile は、ほとんどの場合はお勧めしません。メイクファイル。」

于 2013-09-21T23:50:28.150 に答える
0

スペースの代わりにタブ文字を使用していますか? Web ページにはスペースがありますが、makefile にはタブが必要です。makefile コードの後に​​作成者のコメントがあることに注意してください。

于 2013-06-28T18:04:45.093 に答える