简体   繁体   中英

My makefile isn't finding my include paths

Simply put: It's not finding the include paths:

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)

Your makefile looks pretty broken to me. Firstly, you probably want:

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

Secondly, your final rule needs to be something more like:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM