FFI under Windows

Roman Beslik beroal@ukr.net
Sat, 17 May 2003 15:01:34 +0300

How can I compile C/Haskell program with my own WinMain function?
    I try
ghc -fglasgow-exts -c Foo.hs
gcc -Ie:\ghc\include -c win_ghc.c
ghc -o win_ghc.exe -no-hs-main Foo_stub.o win_ghc.o Foo.o
    and got an error
> ghc -o win_ghc.exe -no-hs-main -lgdi32 Foo_stub.o win_ghc.o Foo.o
e:/ghc/libHSrts.a(Main.o)(.text+0x82):Main.c: undefined reference to
e:/ghc/libHSrts.a(Main.o)(.text+0x93):Main.c: undefined reference to
    Similar works properly:
ghc -fglasgow-exts -c Foo.hs
gcc -Ie:\ghc\include -c ffi.c
ghc -o ffi.exe -no-hs-main Foo_stub.o ffi.o Foo.o
    ffi.c contains main(), but win_ghc.c contains WinMain() instead of

Best regards,
    Roman Beslik.