我的 makefile 有一些问题。 我有以下源代码:main.c cache.c cache.h 当我运行 make 时,它就是我得到的...
make
gcc −ansi −pedantic −Wall −m32 -c main.c
clang: error: no such file or directory: '−ansi'
clang: error: no such file or directory: '−pedantic'
clang: error: no such file or directory: '−Wall'
clang: error: no such file or directory: '−m32'
make: *** [main.o] Error 1
这是我的生成文件:
COMPILER = gcc
CCFLAGS = −ansi −pedantic −Wall −m32
all: c-sim
c-sim: main.o cache.o
$(COMPILER) $(CCFLAGS) -o c-sim main.o cache.o
main.o: main.c
$(COMPILER) $(CCFLAGS) -c main.c
cache.o: cache.c
$(COMPILER) $(CCFLAGS) -c cache.c
clean:
rm -f c-sim
rm -f *.o
这可能是什么问题?
最佳答案
不要使用文字处理器编写脚本。
问题是选项以简单的 - 开头。但是,您已经设法输入了打印破折号。 (与-c
中的-比较,你的-稍微长一点,仔细看。)
这可能是因为您错误地键入了 --
而不是 -
。 Gcc(和 clang)允许但不要求用两个破折号指定长选项(-pedantic 和 -ansi);这是在其他程序中编写长选项的常用方法。许多文字处理器将双破折号“更正”为破折号。
如果您删除破折号并将它们替换为简单的单破折号,一切都会好起来的。
关于c - 我的 makefile 出错,标志没有得到适当处理。可能是什么原因?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27462346/