Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

compile a c++ SDL2 program using the gcc compiler on a mac

I have experience compiling using the gcc compiler on mac, windows, and linux systems and know how to compile will dll's in windows. In this instance, I want to compile a SDL2 program using a mac with the gcc compiler (I have done it on a windows machine); however, when you download the development libraries off the site they do not include any shared library files, only header files. I am currently just a computer science student so I am not the best programmer, if you could help me out compiling a simple SDL2 program showing me all the command prompt options and flags that would be great!

P.S. I do not want to use Xcode to get the job done

like image 743
Dalton Neely Avatar asked Apr 15 '26 22:04

Dalton Neely


1 Answers

First copy the SDL2.framework in the .dmg to your ~/Library/Frameworks. Include the headers in your project #include <SDL2/SDL.h>.

You can then compile it by using:

gcc main.cpp -o main -F/Library/Frameworks -framework SDL2
like image 109
Johan Eriksson Avatar answered Apr 18 '26 12:04

Johan Eriksson