Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Need help with include/Makefile  (Read 1193 times)

0 Members and 1 Guest are viewing this topic.

JakeIzUndead

  • Newbie
  • *
  • Posts: 2
    • View Profile
Need help with include/Makefile
« on: April 03, 2017, 02:16:23 am »
Hello,

im having a little bit of difficulty, my program's directories is setup like this
Makefile
src/
---Game/
---Engine/
---SFML/


the problem is how im declaring the include in my file( i think). I am getting "SFML/Graphics.hpp no such file or directory" and i am declaring it as #include "../SFML/include/SFML/Graphics.hpp" but i have tried a few different ways like <SFML\Graphics.hpp> "SFML\Graphics.hpp"

is my makefile wrong or am i just declaring the include wrong in my .cpp?
makefile:

Quote
CC         := g++
LD         := g++

MODULES      := Game Engine
SRC_DIR      := $(addprefix src\,$(MODULES))
BUILD_DIR   := $(addprefix build\,$(MODULES))
SFML_DIR   := $(addprefix src/,SFML)

SRC         := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.cpp))
OBJ         := $(patsubst src/%.cpp,build/%.o,$(SRC))
INCLUDES   := $(addprefix -I,$(SRC_DIR))
SFML_INC   := $(addprefix -I,$(SFML_DIR)/include)
SFML_LIB_LOC:= $(addprefix -L,$(SFML_DIR)/lib)
SFML_LIB   := -lsfml-graphics -lsfml-window -lsfml-system



vpath %.cpp $(SRC_DIR)

define make-goal
$1/%.o: %.cpp
   $(CC) $(INCLUDES) -c $$< $(SFML_INC) -o $$@
endef

.PHONY: all checkdirs clean

all: checkdirs build/Thantos

build/Thantos: $(OBJ)
   $(LD) $^ -o $@ $(SFML_LIB_LOC) $(SFML_LIB)

checkdirs: $(BUILD_DIR)

$(BUILD_DIR):
   @mkdir $@

clean:
   @rmdir $(BUILD_DIR) /s /q
   
$(foreach bdir,$(BUILD_DIR),$(eval $(call make-goal,$(bdir))))

JakeIzUndead

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Need help with include/Makefile
« Reply #1 on: April 03, 2017, 03:42:17 am »
I finally figured it out, if anyone is curious i misplaced my SFML_INC (inlude folder) instead of going under make-goal it was suppose to be under build job so:

Quote
build/Thantos: $(OBJ)
   $(LD) $(SFML_INC) $^ -o $@ $(SFML_LIB_LOC) $(SFML_LIB)

 

anything