[Haskell-cafe] Building SDL-image package on Windows

Bit Connor bit at mutantlemon.com
Wed Aug 27 04:40:35 EDT 2008

Hi, I wrote the instructions in the WIN32 file.

This looks like the same problem that I originally had with the SDL
package, mangling of "main" function in C land by the hand of the C
SDL.h include file.

If you look at the .hsc files from the SDL package, you will see the
fix I applied at the top of each file, after #including SDL.h the evil
"main" macro is undefined:

#include "SDL.h"
#ifdef main
#undef main

Probably the same must be done for all the .hsc files in SDL-image(and
probably also all other haskell SDL addon packages).

Please let me know if this information is helpful.

2008/8/27 Garrick Chin <nonexistent.ftp+haskellcafe at gmail.com>:
> Hello,
> I'm trying to build the latest SDL-image package (0.5.2) from Hackage on
> Windows and encountering problems.  These are the steps I've taken so far:
> 1.  Downloaded SDL 1.2.13 developmental library for Mingw32 to
> E:\SDL-1.2.13, and SDL_image 1.2.6 developmental library for VC8 to
> E:\SDL_image-1.2.6.
> 2.  Installed SDL package from Hackage, modifying the SDL.cabal according to
> the included WIN32 readme file and then runghc Setup.lhs
> configure/build/install
> 3.  Downloaded the SDL-image package from Hackage, modified the
> SDL-image.cabal file to add the line "Include-Dirs:
> E:\SDL_image-1.2.6\include\SDL, E:\SDL-1.2.13\include\SDL" so Cabal can find
> the header files.  After doing "runghc Setup.lhs configure", "runghc
> Setup.lhs build -v" gives me the following output:
> Creating dist\build (and its parents)
> Creating dist\build\autogen (and its parents)
> Preprocessing library SDL-image-0.5.2...
> Creating dist\build\Graphics\UI\SDL\Image (and its parents)
> E:\ghc\ghc-6.8.2\bin\hsc2hs.exe --cc=E:\ghc\ghc-6.8.2\bin\ghc.exe
> --ld=E:\ghc\ghc-6.8.2\bin\ghc.exe --cflag=-package --cflag=SDL-0.5.4
> --cflag=-package --cflag=base-
> --cflag=-IE:\SDL_image-1.2.6\include\SDL --cflag=-IE:\SDL-1.2.13\include\SDL
> -o dist\build\Graphics\UI\SDL\Image\Version.hs
> Graphics\UI\SDL\Image\Version.hsc
> E:/ghc/ghc-6.8.2/libHSrts.a(Main.o)(.text+0x7):Main.c: undefined reference
> to `__stginit_ZCMain'
> E:/ghc/ghc-6.8.2/libHSrts.a(Main.o)(.text+0x36):Main.c: undefined reference
> to `ZCMain_main_closure'
> collect2: ld returned 1 exit status
> linking dist\build\Graphics\UI\SDL\Image\Version_hsc_make.o failed
> command was: E:\ghc\ghc-6.8.2\bin\ghc.exe
> dist\build\Graphics\UI\SDL\Image\Version_hsc_make.o -o
> dist\build\Graphics\UI\SDL\Image\Version_hsc_make.exe
> The results of a limited google search suggests that the __stginit_ZCMain
> linker error has to do with GHC expecting a main function, but I'm not
> really sure how that works in context of a library.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list