I am writing a make file to compile a very simple SDL2 program.
So far it compiles SDL2 just fine, and now I am working on compiling the extension frameworks SDL2_image and SDL_ttf.
It seems that MAKE is finding the SDL_ttf.h properly, but then SDL_ttf.h cant find "SDL2/SDL.h".
Here is the error:
In file included from main.cpp:3:
/Library/Frameworks/SDL2_ttf.framework/Headers/SDL_ttf.h:30:10: fatal error:
'SDL2/SDL.h' file not found
#include <SDL2/SDL.h>
^
1 error generated.
make: *** [main.o] Error 1
Note, when I included SDL2 like this:
#include <SDL2/SDL.h>
I could not compile even a basic program (SDL2 with no extensions). I got it to work by changing it to this:
#include "SDL.h"
(I also heard the latter syntax is more correct for portability?)
Any ideas?
I am doing this on OS X Mavericks
Here are my files: main.cpp
#include <iostream>
#include "SDL.h"
#include "SDL_ttf.h"
#include "SDL_image.h"
int main(int argc, char * arg[])
{
if(SDL_Init(SDL_INIT_EVERYTHING) != 0)
{
std::cout << "ERROR" <<std::endl;
return -1;
}
SDL_Window * window = SDL_CreateWindow("Name", SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
640,
480,
SDL_WINDOW_OPENGL);
if (TTF_Init() == -1)
{
sdl::cout << "SDL_ttf failed" << std::endl;
}
SDL_Surface* tempSurface = IMG_Load("test.png");
if (tempSurface == nullptr)
{
std::cout << "failed to load test.png" << std::endl;
}
SDL_FreeSurface(tempSurface);
SDL_Delay(5999);
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}
makefile
CXX = clang++
SDL = -framework SDL2 -framework SDL2_ttf -framework SDL2_image
CXXFLAGS = -Wall -c -std=c++11 -I /Library/Frameworks/SDL2.framework/Headers -I /Library/Frameworks/SDL2_ttf.framework/Headers -I /Library/Frameworks/SDL2_image.framework/Header
LDFLAGS = $(SDL) -F /Library/Frameworks
EXE = test
all: $(EXE)
$(EXE): main.o
$(CXX) $(LDFLAGS) $< -o $@
main.o: main.cpp
$(CXX) $(CXXFLAGS) $< -o $@
clean:
rm *.o && rm $(EXE)
Edit:
I have SDL2 and SDL2_ttf installed into the /Library/Frameworks folder per the instructions in the DMG files.