makefile include header解决方案
makefile include header
有一个简单的makefile
总是提示错误:
我很确定 HR_DIR0文件夹中包含了 header1.h header2.h, test.c 和header不在一个文件夹里面
test.c 的开头是
------解决思路----------------------
HDR变量未指定文件夹?
------解决思路----------------------
I guess you'd like to have automake detects header file changes, do you? That can explain why you added header files as prerequisite.
Here is a good reference to explain everything:
http://make.paulandlesley.org/autodep.html
------解决思路----------------------
出现这种问题就用绝对路径试一试 如果可以在相对
------解决思路----------------------
-I$(HR_DIR0) 只是让gcc 能找到这些头文件而已,没有让make也去找,所以HDR 应该是../src/hello/header1.h这样的形式
有一个简单的makefile
HR_DIR0 = ../src/hello
HR_DIR1 =../src/world
CFLAGS = -g -Wall -Werror -m32
CC = gcc
HDR = \
header1.h\
header2.h\
header3.h\
header4.h\
out: test.o
$(CC) $(CFLAGS) -o out test.o
test.o: test.c $(HDR)
$(CC) $(CFLAGS) -I. -I$(HR_DIR0) -I$(HR_DIR1) -I$(HR_DIR0) -c test.c
总是提示错误:
make: *** No rule to make target `header1.h', needed by `test.o'. Stop.
我很确定 HR_DIR0文件夹中包含了 header1.h header2.h, test.c 和header不在一个文件夹里面
test.c 的开头是
#include "header1.h"
#include "header2.h"
#include "header3.h"
#include "header4.h"
------解决思路----------------------
HDR变量未指定文件夹?
------解决思路----------------------
I guess you'd like to have automake detects header file changes, do you? That can explain why you added header files as prerequisite.
Here is a good reference to explain everything:
http://make.paulandlesley.org/autodep.html
------解决思路----------------------
出现这种问题就用绝对路径试一试 如果可以在相对
------解决思路----------------------
-I$(HR_DIR0) 只是让gcc 能找到这些头文件而已,没有让make也去找,所以HDR 应该是../src/hello/header1.h这样的形式