How to build a program with SDL2

Oct 13, 2018 at 2:35am
I have a program which works fine on my computer which uses SDL2. If I send it to someone who has installed the SDL2 developer libraries, it runs fine. But if I send it to someone without it, as you would expect, it doesn't work.

What I'm trying to ask is, is there an easy way to install it or do you have to copy the framework file from the program to the system location?
Oct 13, 2018 at 2:49am
What is a "framework" file? If your executable needs to load functions from DLLs (dynamic-link libraries), then send the DLLs in the same folder as the EXE (i.e. send it wrapped up in a zip or archive file).
Oct 13, 2018 at 3:15am
OK, I didn't explain myself well. I'm developing for a mac. The SDL files are in a .framework. I am aware of how you would do it for a Windows computer, but not for a mac.
Oct 13, 2018 at 3:48am
I am quite sure an .app files in mac is actually an archive directory and you can create a folder inside that called frameworks and throw your .frameworks file in it, but usually that should be done automatically with your IDE. You did include SDL inside of the link-binary-with-library section of build phases right? You may have read a tutorial that told you to put the framework into your list of global frameworks so that you can have a convenient place to find them, but you forgot the important step.
Oct 13, 2018 at 4:14am
How would you do that on Eclipse?
Oct 13, 2018 at 5:19am
https://www.youtube.com/watch?v=EQyAjNMjMkM

At 9:35 is the key to the problem, but take that with a grain of salt since I have not complied anything on a mac.

But I think the video is very poor quality and I think the part of extracting the headers and putting them in a folder as unnecessary (but you should be fine since you already have it working, right?)

If that doesn't work I would double-check if the executable already has SDL2 framework inside the app files, then just manually put the framework in the app to see if that fixes the problem.

Then I would try to port the project to Xcode (If xcode uses the same compiler as eclipse, probably does), compile, and compare the command line output with eachother and see what they do different and figure out how project settings turn to command line options.

Then on a last case scenario I would use Cmake and use the brendan-w/collector/FindSDL2.cmake widget, and generate the eclipse project and settle it (note it is not very easy to learn cmake).
Last edited on Oct 13, 2018 at 1:07pm
Oct 14, 2018 at 1:33pm
I can't put the framework in the executable because when I right-click it doesn't show up with the option to view package contents.
Last edited on Oct 14, 2018 at 1:33pm
Oct 14, 2018 at 4:14pm
My bad, usually people are Windows when they don't specify what the OS is, so it's a force of habit. I don't know enough about macs but here's a tiny bump...
Oct 14, 2018 at 5:21pm
Well you are gonna need to figure it out yourself then.
Topic archived. No new replies allowed.