0

I am trying to compile a basic SDL2 program in C.
This program worked fine on my Artix laptop, where I can simply install the library with pacman and have that be the end of it. but as I'm trying to "port" it to windows, I cannot compile it at all. I tried using the runtime binary (.dll) form the SDL2 website, but all internet results on how to use it were completely incomprehensible.
So, I then tried downloading the folder of headers and including them with #include "SDL2/SDL.h".
When I run gcc main.c, I get undefined references to every SDL_SomeFunction function. I have tried adding various options to the compiler like -lSDL2 or setting -IC:/path/to/stuff, with no luck.
So, what am I missing here?
More importantly, what is the recommended way to do this on Windows? Should I have a completely different approach?

Mao
  • 1
  • 4
    -> [How do I use SDL2 in my programs correctly?](https://stackoverflow.com/questions/64396979/how-do-i-use-sdl2-in-my-programs-correctly) – HolyBlackCat Feb 27 '21 at 21:25
  • ^ The linked thread should everything you need. If not, ask. – HolyBlackCat Feb 27 '21 at 21:25
  • @HolyBlackCat I actually saw that thread while searching because I figured my issue wasn't too special. Upon closer reading of the thread, I added some linker flags `gcc -o app .\main.c -lmingw32 -lSDL2 -lSDL2main -mwindows -LC:.\x86_64-w64-mingw32\lib\` and got a lot less errors, although it still doesn't compile due to missing definitions. – Mao Feb 28 '21 at 02:32
  • 1
    Your flag order is wrong. I believe that post mentions that order matters. – HolyBlackCat Feb 28 '21 at 09:29

0 Answers0