源代码如下:
1 all: myapp
2 CC = gcc
3 INCLUDE = .
4 CFLAGS = -g -Wall -ansi
5 myapp: main.o 2.o 3.o
6 $(CC) -o myapp main.o 2.o 3.o
7 main.o : main.c a.h
8 $(CC) -I$(INCLUDE) $(CFLAGS) -c main.c
9 2.0: 2.c a.h b.h
10 $(CC) -I$(INCLUDE) $(CFLAGS) -c 2.c
11 3.0: 3.c b.h c.h
12 $(CC) -I$(INLCUDE) $(CFLAGS) -c 3.c
命令:make -f makefile2 | tee -a err.txt得到如下信息:
cc -I -c main.c
/tmp/cc4yaYqr.o: In function `main':
main.c:(.text+0x12): undefined reference to `function_two'
main.c:(.text+0x17): undefined reference to `function_three'
collect2: ld 返回 1
make: *** [main.o] 错误 1
为什么宏定义没有引用?不明白:
