Configure SDL2 mac via command line

I am trying to configure SDL2 for use with g ++, a text editor, and a terminal. I have SDL2.framework in / Library / Frameworks. I have a folder on my desktop called testsdl that contains two files:

1) main.cpp

2) makefile

When I type make, I get the following error: main.cpp: 2: 10: fatal error: file "SDL2 / SDL.h" 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 #include to "SDL2 / SDL.h" or just or any other possible combination. I had no problems configuring it through Xcode, but I cannot figure out how to do this without using the IDE.

: , , SDL , ? .

+4
2

/Users/path/where/i/unzipped/SDL2-2.0.5

sdl2-config --cflags --libs

, SDL

, , :

g++ -std=c++11 main.cpp -o main.exe `sdl2-config --cflags` `sdl2-config --libs`

make,

0

, -F /Library/Frameworks CXXFLAGS. :

g++ -Wall -F /Library/Frameworks -c -o main.o main.cpp
g++ main.o -o main -framework SDL2 -I /Library/Frameworks/SDL2.framework/Headers

makefile, OSX 10.12.6:

CXX = g++

CXXFLAGS = -Wall -F /Library/Frameworks
LDFLAGS = -framework SDL2 -F /Library/Frameworks -I /Library/Frameworks/SDL2.framework/Headers

all: main

main: main.o
    $(CXX) main.o -o main $(LDFLAGS)

obj/main.o : main.cpp
    $(CXX) $(CXXFLAGS) -c main.cpp -o main.o

clean:
    rm main.o main
0

Source: https://habr.com/ru/post/1616315/


All Articles