[Hackage] #504: executables with a C main function

Hackage cvs-ghc at haskell.org
Tue Apr 19 00:54:44 CEST 2011

#504: executables with a C main function
  Reporter:  duncan           |        Owner:         
      Type:  enhancement      |       Status:  new    
  Priority:  normal           |    Milestone:         
 Component:  Cabal library    |      Version:
  Severity:  normal           |     Keywords:         
Difficulty:  easy (<4 hours)  |   Ghcversion:         
  Platform:                   |  
Changes (by jcpetruzza):

 * cc: jcpetruzza@… (added)


 I believe the lack of this feature makes SDL-based applications currently
 unbuildable on OS X.

 On OS X, SDL.h "renames" (using a macro) the "main" function to
 "_SDL_main"; the latter is then called from a "main" function defined in
 libSDLmain.a (with which every SDL-based program has to be linked). For
 this to work with Haskell, the workaround suggested in the SDL package is
 to use a C wrapper which includes SDL.h and defines a "main" function that
 calls, via the FFI, the entry-point of the haskell application.

 Notice that the workaround suggested in the ticket description does not
 work in this case, since the "main" function defined in the haskell
 wrapper would collide with the one in libSDLmain.a when linked.

 Observe also, that for this feature to work in a mixed Haskell/C setting
 like the one described, the .c program cannot be compiled first (as I
 think is the case with declared c-files), since it will need to #include
 the stubs generated from processing FFI export declarations.

Ticket URL: <http://hackage.haskell.org/trac/hackage/ticket/504#comment:3>
Hackage <http://haskell.org/cabal/>
Hackage: Cabal and related projects

More information about the cabal-devel mailing list