
Hello, I've been trying for a while to build the SDL haskell library on windows. People have told me it worked for them, but I can't get to work for the life of me. I have the latest Haskell Platform, I think more or less the latest MINGW and MSYS tools. I'm on Windows 7 64 bits. I installed the SDL library without hassle, and the samples work. It's only the haskell library that's bothering me. I've modified the .cabal file as indicated for Windows (extra-include-dirs, extra-lib-dirs), and runhaskell Setup configure. But then runhaskell Setup build fails with: Preprocessing library SDL-0.5.9... dist\build\Graphics\UI\SDL\General_hsc_make.o:General_hsc_make.c:(.text +0x29): m ultiple definition of `main' d:/dev/mingw/bin/../lib/gcc/mingw32/4.5.0/../../../ libmingw32.a(main.o):main.c:( .text+0x0): first defined here D:\dev\SDL-1.2.14\lib/libSDLmain.a(SDL_win32_main.o): In function `console_main' : /Users/hercules/trunk/SDL-1.2/./src/main/win32/SDL_win32_main.c:315: undefined r eference to `SDL_main' collect2: ld returned 1 exit status linking dist\build\Graphics\UI\SDL\General_hsc_make.o failed command was: d:\dev\MinGW\bin\gcc.exe -LD:\dev\SDL-1.2.14\lib -L/usr/ lib -lmingw 32 -lSDLmain -lSDL -mwindows -LD:\dev\haskell\HaskellPlatform \2010.1.0.0\base-4. 2.0.0 -lwsock32 -luser32 -lshell32 -LD:\dev\haskell\HaskellPlatform \2010.1.0.0\i nteger-gmp-0.2.0.0 -LD:\dev\haskell\HaskellPlatform\2010.1.0.0\ghc- prim-0.2.0.0 -LD:\dev\haskell\HaskellPlatform\2010.1.0.0 -LD:\dev\haskell \HaskellPlatform\201 0.1.0.0/gcc-lib -lm -lwsock32 -LD:\dev\haskell\HaskellPlatform \2010.1.0.0 dist\b uild\Graphics\UI\SDL\General_hsc_make.o -o dist\build\Graphics\UI\SDL \General_hs c_make.exe (I have the same error with the gcc inside the Haskell Platform, the same error running in a windows shell without MSYS on the path, in the MSYS bash with MSYS on the path). And I figured out what's wrong with that line after thinking for a while (as in, several days...): basically the line says something like gcc sdl-flags file.o -o file.exe. If I revert the order of the arguments and run gcc file.o -o file.exe sdl-flags, it works! The gcc documentation explains that the libraries are searched in the order they appear (http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html), so to put the libraries you depend on after the code that has the dependencies. And I can see that building the SDL samples indeed puts the .c file before the sdl linker flags. So this seems to be my problem. What's the solution? 1. I've done something stupid or forgot some essential MINGW tool that would make my system not dependent on the order of the arguments to gcc? I've tried with gcc 3.4.5 and gcc 4.5.0, same result. 2. I can hack somewhere (where???) the command passed on to GCC when building? Maybe some voodoo in the cabal file? 3. I can get runhaskell Setup build to only dump the commands it's going to run, modify them in my favorite text editor and run them manually (as said above, I've managed to create the first exe required but build insists on rebuilding it even if present) 4. ...? The fact that some people managed seem to point with a problem with my config, but it's seems reasonnably clean to me, and I've even managed to install wxWidgets and wxHaskell... Any help appreciated! -- JP Moresmau http://jpmoresmau.blogspot.com/