makefile中宏定义的引用问题

软件和网站开发以及相关技术探讨
回复
everyhope
帖子: 13
注册时间: 2009-03-30 14:24

makefile中宏定义的引用问题

#1

帖子 everyhope » 2009-05-06 15:44

刚开始学习写makefile文件,遇到了下面问题,请高手指教,不胜感激!
源代码如下:
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

为什么宏定义没有引用?不明白: :em03
上次由 everyhope 在 2009-05-06 15:47,总共编辑 1 次。
everyhope
帖子: 13
注册时间: 2009-03-30 14:24

Re: makefile中宏定义的引用问题

#2

帖子 everyhope » 2009-05-06 15:46

为什么会出现cc -I -c main.c,$(CC)不是就应是gcc吗?
回复