As the title states I'm trying to create a makefile for compiling C++ programs using SDL2 on Windows. I have MinGW installed and working. I'm using Sublime 2 as my environment. Here's what I have so far:
CXX = g++ CXXFLAGS = -std=c++0x -g -O3 -w -Wl,-subsystem,windows INCLFLAGS = -IC:\Libraries\i686-w64-mingw32\include\SDL2 LDFLAGS = -LC:\Libraries\i686-w64-mingw32\lib -lmingw32 -lSDL2main -lSDL2 OBJECTS = main.o TARGET = 1_hellosdl $(TARGET) : $(OBJECTS) $(CXX) $(INCLFLAGS) $(LDFLAGS) $(CXXFLAGS) -o $(TARGET) $(OBJECTS) main.o : clean: rm -rf $(OBJECTS) $(TARGET) remake: clean $(TARGET)
Right now when I compile I get the following error:
g++ -std=c++0x -g -O3 -w -Wl,-subsystems,windows -c -o main.o main.cpp In file included from main.cpp:1:0: main.hpp:4:17: fatal error: SDL.h: No such file or directory #include <SDL.h>
So the issue is that
g++ can't find the SDL include file when it tries to compile main.cpp. I get that this is because
$(INCLFLAGS) isn't being added to the line under
Optimally, I'd like to specify
INCLFLAGS implicitly similar to
LDFLAGS, but based on this it doesn't look like it's possible.
Is there a way to do this using an implicit variable or, failing that, what's the best alternative? Is there anything else I am doing wrong?