[MLton] Support for link options in ML Basis files

Chris Clearwater chris@detriment.org
Thu, 20 Jan 2005 16:27:44 -0800

Matthew Fluet wrote:

>>Does all the above include compiling with MLton or is that just for
>>stand-alone C-programs? I had to include SDL.h in the MLton runtime,
>Could this have been a consequence of older versions of MLton not 
>generating proper C-prototypes for imported functions?
I believe the problem he is refering to is that on windows, SDL assumes 
you are compiling the main executable with a C compiler and including 
"SDL/SDL.h". It does this to assist with the fact that Windows has a 
different entry symbol with a different prototype than "main" used most 
everywhere else (Maybe Mac OS is different as well?). To remedy this, 
SDL defines the entry symbol itself and makes "main" a macro that 
expands to SDL_main which it will call from the real main. Fortunately 
the symbol is defined in a seperate static library 
SDLmain.lib/libSDLmain.a and it really only applies to compiling with 
MSVC as the MingW32 gcc will fix the main symbol for you. If you use the 
flags sdl-config tells you to use it will try to link -lSDLmain and it 
will conflict with MLton's main. Simply stripping -lSDLmain from the 
link-opts fixed it for me.