Nathaniel J Fries wrote:
SDL does not attempt to replace the C runtime. You need to link to the Visual C++ runtime (which includes both the security cookie and _WinMainCRTStartup)!
That’s very clear, thanks.
I do not want to get rid of VC runtime if it’s not supported by SDL.
I do want to get the static VC runtime (libcmt.lib) instead of the dynamic VC runtime (msvcrt.lib) though.
Sam Lantinga wrote:
I’ve run into the chkstk assertion when I allocate more than 4k in a stack frame. If you’re allocating that much, I would recommend using SDL_stack_alloc() / SDL_stack_free() or dynamically allocating the data you need.
I am not allocating anything. The application crashes before my main is called, unless I remove _chkstk in SDL_stdlib.c. It seems that libcmt.lib does not want anyone else to declare _chkstk.
Jared Maddox wrote:
Ok, but what is your actual reason for WANTING to statically link everything?
I want a single file executable. I think that it’s the ideal way to distribute a very small game.
Don’t get me wrong, I have nothing against VC runtime.
I absolutely don’t want to implement a runtime by myself, but I want to use the static runtime provided by Microsoft (libcmt.lib), which is a method supported by Microsoft.
You can see that in the first chart in the link sent by Jared: http://msdn.microsoft.com/en-us/library/abx4dbyh(v=vs.80).aspx
My understanding is that SDL_stdlib.c and libcmt.lib conflict with each other.
You can find a reproduction solution - VS 2012 - here: http://www.files.com/set/517a947761bda
It contains three configurations:
- ‘Libcmt with _chkstk’ > produces the error
- ‘Libcmt without _chkstk’ > no error
- ‘Msvcrt’ > no error
(includes and libs are in the solution, so it should build straighforwardly)
Regarding the two other topics we discussed yesterday:
- Yes, I don’t want CLR, I read the microsoft MSDN page too quick yesterday
- When linking SDL_image, I still get the _fltused conflict (between SDL_stdlib.c and libcmt.lib) even though I link everything at the very last step. I don’t want to make this thread too complex, so maybe we can let it aside for now, but I can setup a reproduction solution if you wish.