Hi *,
In the IRC channel freenode/#SDL, a lot of people come by struggling
with getting SDL2 to work due to
http://wiki.libsdl.org/FAQWindows#I_get_.22Undefined_reference_to_.27SDL_main.27.22_…
Even despite following compiler options, many have trouble getting it to work.
I use SDL 1.2 and SDL 2 for some years myself already, but I still
have one project where this part fails too, and I still haven’t
figured out why, just for this particular project (works for all my
others). I worked around it by peeking on SDL_windos_main.c, and then
just manually calling SDL_SetMainReady and ignoring command line
arguments for SDL.
Anyway, really a LOT of people seem to get stuck on this (judging by
newcomers stumbling into IRC with all of them having this issue) even
if they apparently seem to use the correct linker flags, and
apparently all this is for is “magic” command line parsing of SDL
behind the scenes and main everywhere instead of WinMain?
Let me suggest a consideration whether the trouble this feature causes
and the benefit it brings are a good trade.
Was there ever a consideration of having SDL_Init manually take the
command line arguments instead through parameters or something, and
have the windows applications own their regular WinMain themselves?
I guess without all this magic stuff, people would need to use WinMain
or int main on depending on the platform, and the main function of SDL
apps would no longer be platform independent.
But isn’t there another way? E.g. a macro that should be used instead
of a main which expands to main or WinMain depending on the platform,
then passing the arguments to SDL_Init explicitely?
Just something that is less of a linker hack. (since it seems to cause
a lot of issues for many newcomers)
Regards,
Jonas Thiem