[英]Why aren't compiler flags I specify in my makefile showing up in my terminal (Cygwin) output?
So I'm trying to run C code with a Cygwin terminal and I have a makefile called Makefile.mak with the following in it:所以我正在尝试使用 Cygwin 终端运行 C 代码,我有一个名为 Makefile.mak 的 makefile,其中包含以下内容:
CFLAGS=-Wall -g
clean:
rm -f ex3
The book I have "Learn C the Hard Way" says I need to use the command "make clean", however, when I write this I get the error我的书“Learn C the Hard Way”说我需要使用命令“make clean”,但是,当我写这个时,我得到了错误
make: *** No rule to make target 'clean'. Stop.
It only works if I type仅当我键入时才有效
make -f Makefile.mak clean."
The next problem is that when I try the make command on my C file (ex3.c) I get the output下一个问题是,当我在 C 文件(ex3.c)上尝试 make 命令时,我得到 output
cc ex3.c -o ex3
yet I am supposed to see the flags in that output from my makefile as well.但是我也应该从我的 makefile 中看到 output 中的标志。 Like this:
像这样:
cc -Wall -g ex3.c -o ex3.
I've tried changing the settings in my gcc compiler and still nothing.我尝试更改 gcc 编译器中的设置,但仍然没有。
I also have the makefile and my C code file in the same file path.我在同一文件路径中还有 makefile 和我的 C 代码文件。
Any help would be greatly appreciated.任何帮助将不胜感激。
The filename Makefile.mak is not picked up by make
by default.文件名 Makefile.mak 默认不被
make
拾取。 You need to name it either "makefile" or "Makefile" for that.为此,您需要将其命名为“makefile”或“Makefile”。
As for the compile command, you didn't specify a target on how to build ex3.至于编译命令,您没有指定如何构建 ex3 的目标。 You need to add that:
您需要添加:
ex3: ex3.c
cc $(CFLAGS) -o $@ $^
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.