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>
with:
/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!
Stefan

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_main.h
/Library/Frameworks/SDL2.framework/Headers/SDL_stdinc.h
/Library/Frameworks/SDL2.framework/Headers/SDL_config.h
/Library/Frameworks/SDL2.framework/Headers/SDL_platform.h
/Library/Frameworks/SDL2.framework/Headers/begin_code.h
/Library/Frameworks/SDL2.framework/Headers/close_code.h
/Library/Frameworks/SDL2.framework/Headers/SDL_config_macosx.h
/Library/Frameworks/SDL2.framework/Headers/SDL_assert.h
/Library/Frameworks/SDL2.framework/Headers/SDL_atomic.h
/Library/Frameworks/SDL2.framework/Headers/SDL_audio.h
/Library/Frameworks/SDL2.framework/Headers/SDL_error.h
/Library/Frameworks/SDL2.framework/Headers/SDL_endian.h
/Library/Frameworks/SDL2.framework/Headers/SDL_mutex.h
/Library/Frameworks/SDL2.framework/Headers/SDL_thread.h
/Library/Frameworks/SDL2.framework/Headers/SDL_rwops.h
/Library/Frameworks/SDL2.framework/Headers/SDL_clipboard.h
/Library/Frameworks/SDL2.framework/Headers/SDL_cpuinfo.h
/Library/Frameworks/SDL2.framework/Headers/SDL_events.h
/Library/Frameworks/SDL2.framework/Headers/SDL_video.h
/Library/Frameworks/SDL2.framework/Headers/SDL_pixels.h
/Library/Frameworks/SDL2.framework/Headers/SDL_rect.h
/Library/Frameworks/SDL2.framework/Headers/SDL_surface.h
/Library/Frameworks/SDL2.framework/Headers/SDL_blendmode.h
/Library/Frameworks/SDL2.framework/Headers/SDL_keyboard.h
/Library/Frameworks/SDL2.framework/Headers/SDL_keycode.h
/Library/Frameworks/SDL2.framework/Headers/SDL_scancode.h
/Library/Frameworks/SDL2.framework/Headers/SDL_mouse.h
/Library/Frameworks/SDL2.framework/Headers/SDL_joystick.h
/Library/Frameworks/SDL2.framework/Headers/SDL_gamecontroller.h
/Library/Frameworks/SDL2.framework/Headers/SDL_sensor.h
/Library/Frameworks/SDL2.framework/Headers/SDL_quit.h
/Library/Frameworks/SDL2.framework/Headers/SDL_gesture.h
/Library/Frameworks/SDL2.framework/Headers/SDL_touch.h
/Library/Frameworks/SDL2.framework/Headers/SDL_filesystem.h
/Library/Frameworks/SDL2.framework/Headers/SDL_haptic.h
/Library/Frameworks/SDL2.framework/Headers/SDL_hidapi.h
/Library/Frameworks/SDL2.framework/Headers/SDL_hints.h
/Library/Frameworks/SDL2.framework/Headers/SDL_loadso.h
/Library/Frameworks/SDL2.framework/Headers/SDL_log.h
/Library/Frameworks/SDL2.framework/Headers/SDL_messagebox.h
/Library/Frameworks/SDL2.framework/Headers/SDL_metal.h
/Library/Frameworks/SDL2.framework/Headers/SDL_power.h
/Library/Frameworks/SDL2.framework/Headers/SDL_render.h
/Library/Frameworks/SDL2.framework/Headers/SDL_shape.h
/Library/Frameworks/SDL2.framework/Headers/SDL_system.h
/Library/Frameworks/SDL2.framework/Headers/SDL_timer.h
/Library/Frameworks/SDL2.framework/Headers/SDL_version.h
/Library/Frameworks/SDL2.framework/Headers/SDL_locale.h
/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

Hello again, here are some news in my case after reading some stuff in the Internet:

Quite weirdly, the headers in //Library/Frameworks/SDL2.framework/Headers are found during compilation if i replace in the SDL2 headers, e.g.
#include <SDL2/SDL_config.h>
by
#include <SDL_config.h>

Of course this is not as it should be, but does not give a hint what is wrong in my configuration?