cxcodegccsdlsdl-2

How do I install SDL2 on mac using C preferably without X-Code?


I am using C and building a game I have tried every forum out there. Most seem to be in C++ and I would like to use SDL2 with C. I am using gcc compiler and the furthest I got was for it to compile with GCC but no window would appear. I did not code this, I grabbed it from a tutorial. I have tried with brew and the framework.

Could somebody please walk me through the install process to get it working either with gcc or xcode

EDIT: On Catalina 10.15.6

thanks


Solution

  • Okay, I figured it Out, those who are also having trouble you can here is my solution,

    You download and install the framework into Library/Frameworks then once you are done that you will be able to compile using gcc with this command

    gcc main.c -o run -I/Library/Frameworks/SDL2.framework/Headers -F/Library/Frameworks -framework SDL2 -I/Library/Frameworks/SDL2_image.framework/Headers -F/Library/Frameworks -framework SDL2_image
    

    How ever as I mentioned before you can get the code to compile without a window appearing so here is the solution full credit to the forums and the User Sjr

    https://discourse.libsdl.org/t/sdl2-compiles-but-doent-open-a-window-when-run/26867

    and here is a link to how I got the compiler to work

    https://youtu.be/BCcvwoIOHVI

    The compile command is different so look in the comments the reply by ikokujin to the comment by Phraggers with a couple edits by me to include gcc -o run

    Hope this info help's everyone who was stuck on this in their sdl2 project on Mac.

    Thanks, Winter_Ice