c++ - Makefile 奇怪的错误

标签 c++ c makefile

这是我的 makefile,每当我执行 make 或 make clean 时,我都会收到此错误: “makefile:11: * 缺少分隔符。停止。” 我很确定我做对了,但不确定为什么会出现此错误。这是我第一次处理这个错误,所以我不知道如何修复或解决它......

 COMPILER = gcc
 CCFLAGS = -g -Wall
 CFLAGS2 = -g

 all: malloc test

 debug:
make DEBUG=TRUE

 malloc.o: malloc.c malloc.h
$(COMPILER) $(CCFLAGS) -c malloc.c malloc.h

 malloc: malloc.o
$(COMPILER) $(CCFLAGS) -o malloc malloc.o

 test.o: test.c
$(COMPILER) $(CFLAGS2) -c test.c

 test: malloc.o test.o
$(COMPILER) $(CCFLAGS) -o test test.o malloc.o

 ifeq ($(DEBUG), TRUE)
  CCFLAGS += -g
 endif

 clean:
rm -f malloc
rm -f *.o
rm -f test
rm -f *.o



ERROR
  "makefile:11: *** missing separator.  Stop."

最佳答案

Makefile 要求您在所有配方行的开头都有一个制表符。

 target ... : prerequisites ...
 <TAB>recipe
 <TAB>...
 <TAB>...

关于c++ - Makefile 奇怪的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23436656/

相关文章:

在 Sublime Text 2 (gcc) 中编译并运行 C

android - AOSP 构建 - 从 eng 切换到 user 或 userdebug 时,不再创建数据目录

c++ - RPath 不适用于从 CMake 生成的 Make Install

c - 使用 make 将多个 .c 文件链接到一个程序中?

c++ - CPP : avoiding macro expansion of a macro function parameter

c++ - 如何将 vector 的大小作为 int 获取?

c++ - 只有在 header 中定义的函数才会被内联。我错过了什么吗?

c++ - 如何在自动循环中使用 s.end() 之类的东西?

c++ - 让奴隶在MPI中互相等待

c++ - C中数据的功能责任