3

I am trying to include the SDL library in my c++ project. I have installed the SDL2.framework and included it in Library/Frameworks. I have also run the following commands in the terminal:

brew install SDL2
brew install SDL2_Image

However, when I try to compile using my makefile:

OBJS=texture.cpp window.cpp

LFLAGS=-lSDL2 -lSDL2_image
CURRDIR=`pwd`
.PHONY: test

all: test

test: $(OBJS) test.o
    g++ -std=c++11 -Wall $(OBJS) test.o $(LFLAGS)

test.o: test.cpp
    g++ -c -std=c++11 -DSPRITEFILENAME="\"$(CURRDIR)/sprites.png\"" -Wall test.cpp -o test.o

I get the following error:

./texture.h:7:10: fatal error: 'SDL2/SDL.h' file not found
#include <SDL2/SDL.h>
         ^
1 error generated.
make: *** [test.o] Error 1

Any help will be appreciated.

  • 2
    It looks like the SDL2 folder is not in your path (`brew info SDL2` should show you where this is), point there with the -I flag (capital i for include) – Andy M Aug 10 '16 at 18:47
  • Definitely a duplicate of: http://stackoverflow.com/questions/20277477/how-do-you-include-files-in-c-from-the-library-framework-folder-in-mac – Shaun Ramsey Aug 10 '16 at 18:48
  • /usr/local/Cellar/SDL2/2.0.4 -This is what gets returned from brew info SDL2 – Nicholas Ferretti Aug 10 '16 at 18:48

0 Answers0