我的makefile没有找到我的包含路径

时间:2011-05-01 23:56:00

标签: c++ gcc makefile include-path

简单地说:它没有找到包含路径:

CC = g++
OBJS = *.o #*/*.o

DEBUG = -g
PNAME = game
INCLUDES = -Iheaders

CFLAGS = -Wall $(DEBUG)
LFLAGS = -Wall -lsfml-graphics -lsfml-window -lsfml-system $(DEBUG)

all: build

build: $(OBJS)
    $(CC) $(LFLAGS) $(OBJS) -o $(PNAME)

clean:
    \rm *.o *~ $(PNAME)

.cpp:
    $(CC) $(CFLAGS) $(INCLUDES) -c $(.SOURCE)

1 个答案:

答案 0 :(得分:5)

你的makefile看起来很糟糕。首先,您可能想要:

OBJS = $(patsubst %.cpp,%.o,$(wildcard *.cpp))

其次,你的最终规则需要更像:

%.o: %.cpp
    $(CC) $(CFLAGS) $(INCLUDES) -c $^ -o $@