MacOS - fatal error: 'SDL2/SDL_main.h' file not found (since SDL 2.24.0)

Dear all, I try to help the maintainer of this repository with MacOS builds:

Starting with SDL version 2.24.0, compilation fails (both X64 and Apple Silion) on:
#include <SDL.h>
/Library/Frameworks/SDL2.framework/Headers/SDL.h:32:10: fatal error: ‘SDL2/SDL_main.h’ file not found

SDL version 2.0.22 still works.

Unfortunately I do not code, so my possibilities are very limited, while the repo owner does not own a Mac. Therefore I would be grateful for some hints, as Google researches did not provide me with something feasible.

Many thanks in advance!

Something is wrong with the SDL2.framework on your system (ignoring the part where you’ve put it at a system location instead of inside the app bundle because you aren’t a programmer :stuck_out_tongue_winking_eye: ).

I just downloaded SDL 2.24.0 and it has SDL_main.h in it.

IDK how familiar you are with the command line, but open the Terminal app and type

ls -l /Library/Frameworks/SDL2.framework/Headers/SDL_main.h

and tell us what it says.

You could also try the latest version of SDL2, which is 2.26.2, and see if that fixes anything.

Hi, and many thanks, well at least I am familiar with the Terminal ;-).

Output (actually on SDL 2.26.2):
myname@10 ~ % ls -l /Library/Frameworks/SDL2.framework/Headers/SDL_main.h
-rw-r–r–@ 1 myname wheel 8824 3 Jan 15:57 /Library/Frameworks/SDL2.framework/Headers/SDL_main.h

Output (on 2.0.22 - the last that works):
-rw-r–r–@ 1 myname wheel 7588 25 Apr 2022 /Library/Frameworks/SDL2.framework/Headers/SDL_main.h
I have tested every single SDL version since then, including 2.26.2.

Thinking out loudly: Could a parallel Homebrew SDL2 install make troubles? SDL2 is required by some other Homebrew packages. Sorry for not being of much more help…

Probably not. My system has some homebrew packages that have SDL2 installed, and I am able to successfully build my own apps using my own SDL2.framework that I bundle with the app.

edit: it looks like the build process for this app expects to have SDL2 installed in /Library/Frameworks and pokes around inside the SDL2 framework for info (which seems kind of… brittle). Weird that it can’t find SDL_main.h, since it’s clearly right there.

I’d help more, but I can’t get this app’s build system to get the point where it starts poking around inside SDL2.framework. It apparently needs some “xmlpatterns” module that the Homebrew version of QT5 doesn’t install and I’m not familiar enough with QT’s build system to figure it out.

A bit of delay on my side, sorry for this. I just re-ran the compile with the last functioning version 2.0.22 and with 2.26.2 → then a comparison of the Makefile.qmake with Meld shows many sigificant differences (apparently numerous times, and SDL2 headers being the only difference between the Makefiles!):

The Makefile.qmake of the new SDL version only has this:
/Library/Frameworks/SDL2.framework/Headers/SDL.h \

Whereas the Makefile.qmake of the old SDL version also has these:
/Library/Frameworks/SDL2.framework/Headers/SDL_misc.h \

With otherwise identical code base. I will now just look what happens if I merge these differences into the new Makefile.qmake - as a rude workaround.

Too easy … does not work.

Yeah, SDL.h includes all those other files so they don’t need to be individually specified.

I’d probably get ahold of the developer and see what they can do. I’m not familiar enough with QT or qmake to be of much help.

1 Like