I am writing a make file to compile a very simple SDL2 program.
While it compiles SDL2 just fine, and now I'm working on compiling the SDL2_image and SDL_ttf extension infrastructures.
It seems that MAKE correctly finds SDL_ttf.h, but then SDL_ttf.h cannot 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
^
1 error generated.
make: *** [main.o] Error 1
Notice when I turned on SDL2, like this:
#include <SDL2/SDL.h>
I could not compile even the base program (SDL2 without extensions). I got it for work, changing it to this:
#include "SDL.h"
(I also heard that the latter syntax is more correct for portability?)
Any ideas?
I do it 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 in the / Library / Frameworks folder according to the instructions in the DMG files.