I'm trying to setup SDL2 to use with g++, a text editor and terminal. I have my SDL2.framework in /Library/Frameworks. I have a folder on my desktop named testsdl which contains two files:
1) main.cpp
2) makefile
when I type make I get the following error:main.cpp:2:10: fatal error: 'SDL2/SDL.h' file not found. here is a copy of my makefile
CXX = g++
SDL = -framework SDL2
CXXFLAGS = -Wall -c -std=c++11 -I ~/Library/Frameworks/SDL2.framework/Headers
LDFLAGS = $(SDL) -F /Library/Frameworks -F ~/Library/Frameworks/
EXE = SDL_Lesson0
all: $(EXE)
$(EXE): main.o
$(CXX) $(LDFLAGS) $< -o $@
main.o: main.cpp
$(CXX) $(CXXFLAGS) $< -o $@
clean:
rm *.o && rm $(EXE)
and here is a copy of main.cpp:
#include <iostream>
#include <SDL2/SDL.h>
int main(int, char**)
{
if (SDL_Init(SDL_INIT_VIDEO) != 0)
{
std::cout << "SDL_Init Error: " << SDL_GetError() << std::endl;
return 1;
}
SDL_Quit();
return 0;
}
I tried changing the #include to "SDL2/SDL.h" or just or any other possible combination. I had no problem setting it up through Xcode but can't figure out how to do it without using an IDE.
a second part of the question is: if I wanted to include the frameworks in the project folder itself so I can later distribute the binaries to people who do not have SDL on their machines how would I do that? thanks.
-Iand path~/Library/Frameworks/SDL2.framework/Headers? Normally there is not a space between-I,-L,-l, or any other compiler flags and their parameters. (2) Does~/Library/Frameworks/SDL2.framework/Headers/SDL2/SDL.hactually exist? If not then there is your problem. (3) If you want the compilation to be cross-platform (i.e. work on linux / bsd / windows) then I guess you should stay away from-frameworkalso and use-L -linstead - Chris Beck