当前位置: 技术问答>linux和unix
请教个Makefile的头文件包含问题
来源: 互联网 发布时间:2016-11-01
本文导语: 本帖最后由 yhguo2008 于 2011-01-02 13:48:32 编辑 目前小弟刚学Makefile,写了个程序,总是报错找不到头文件point.h: g++ -W -g -MM -c -o src/point/point.o src/point/point.cpp src/point/point.cpp:1:19: error: point.h: No such file or direct...
g++ -W -g -MM -c -o src/point/point.o src/point/point.cpp
src/point/point.cpp:1:19: error: point.h: No such file or directory
make: *** [src/point/point.o] Error 1
程序如下:
目录结构:
|
|--include
| |---point.h
|
|--Makefile
|
|--src
| |--main
| | |---main_point.cpp
| |
| |--point
| |---point.cpp
|
在point.h中声明了Point类,Point类中的成员函数定义在point.cpp中,并且#include "point.h", main_point.cpp中是主函数,也#include "point.h"
Makefile是写成这样的:
CPP = g++
CXXFLAGS = -W -g -MM
INCLUDE= -I./include
.PHONY:all clean
TARGETS = main_point
all:$(TARGETS)
main_point: ./src/point/point.o ./src/main/main_point.o
$(CPP) $(CXXFLAGS) -o $@ $^
point.o: ./src/main/point.cpp
$(CPP) -c $(CXXFLAGS) $(INCLUDE)-o $@ $