0

I created a make file to run a sdl2 window

Make file

all:
    g++ -I src/include -L src/lib -o main.cpp -lmingw32 -lSDL2main -lSDL2

Opened a new terminal and the command ''make'' doesn't create my .exe file, it isn't really recognized at all

is there an easier way to use the cmd terminal to create an .exe file with sdl2?

I tried going the cmd path : g++ -o main main.cpp

and the result was:

main.cpp:2:10: fatal error: SDL2/SDL.h: No such file or directory
    2 | #include <SDL2/SDL.h>
      |          ^~~~~~~~~~~~
compilation terminated.

So apparently the problem is that my file doesn't include SDL.h even tho it is present in the SDL folder.

Also cmd straight out deleted my ''main.cpp' file.

Also tried mingw32-make in the terminal and it also deleted my main.cpp file and found the same errors.

genpfault
  • 51,148
  • 11
  • 85
  • 139
Lost
  • 1
  • @john it returns 1 after failing to find SDL2 a few times and deletes my main.cpp – Lost Dec 07 '22 at 11:43
  • Yes I just realised, the command is wrong Try this `g++ -I src/include -L src/lib -o main main.cpp -lmingw32 -lSDL2main -lSDL2` – john Dec 07 '22 at 11:44
  • 1
    After `-o` you put the name you want for the executable. Your makefile command is missing that, so it thinks you want to call the executable `main.cpp`. – john Dec 07 '22 at 11:45
  • But if that still fails because it can't find SDL, then you have another problem. – john Dec 07 '22 at 11:47
  • @john thanks, this was quite a stupid and easy problem to run into, thank you very much! – Lost Dec 07 '22 at 11:54
  • Make on Windows can be installed from [MSYS2](https://stackoverflow.com/questions/30069830/how-to-install-mingw-w64-and-msys2). – HolyBlackCat Dec 07 '22 at 17:03

0 Answers0