makefile奇怪的问题
1 CC=gcc
2 DEBUG=debug/$@
3
4 vpath % debug:src:inc
5
6 main:main.o print.o
7 ${CC} -o ${DEBUG} $^
8
9 main.o:main.c print.h
10 ${CC} -c -o ${DEBUG} $<
11
12 print.o:print.c print.h
13 ${CC} -c -o ${DEBUG} $<
14
15 clean:
16 rm -f debug/*
第一次make时,成功生成.o文件 但是执行链接的时候却没有去debug目录去找 我写了 vpath % debug:src:inc 。make程序能去src去找,为什么不能去debug找。更奇怪的是第二次make 却能到debug下去找.o了
[解决办法]
9 [color=#FF0000]main.o[/color]:main.c print.h 10 ${CC} -c [color=#FF0000]-o ${DEBUG}[/color] $<