[Haskell-cafe] Distributing Haskell binaries as OSX App Bundles

Corey O'Connor coreyoconnor at gmail.com
Tue Sep 30 13:24:26 EDT 2008


2008/9/24 Stephen <analytic at gmail.com>:
> I wrote a command-line program recently for a friend in haskell.  However,
> he's far away and not particularly computer literate.  I sent him the raw
> binaries, but they came up with errors about not being able to find libgmp
> stuff.  So then I thought I should probably be able to somehow distribute
> all the stuff together in a .app bundle.  However, the only experience I
> have of doing this sort of stuff before is via xcode.  What's the best way
> to go about this?  It just occurred to me now that maybe cmake is the way to
> go?

A long time ago I solved this problem by creating Cabal user hooks to
package the binary into a .app bundle. The code is located here:
http://tothepowerofdisco.com/repo/HaskellLibraries/

This isn't really quality code IMO. The version of cabal this works
with is limited to that distributed with GHC 6.6 and the version of
GHC 6.6 that dynamically linked with GMP.framework stored in
/Library/Frameworks. Plus the package includes Core Audio and Core
Foundation wrappers which really have nothing to do with packaging
haskell applications into .app bundles. Still, it worked and I was
able to create self-contained OS X applications.

The reason the dynamically linked GMP framework was used instead of
the statically linked GMP was due to the GMP license. This complicates
creating a self-contained application but it is still possible. The
technique I used was to rewrite the install name of GMP.framework to
be executable relative and copy the framework into the application
bundle. Course, the downside is this increases the application size by
around 2mb!

See: appPackageExe in
http://tothepowerofdisco.com/repo/HaskellLibraries/MacOSX/Build.hs

If there is interest in a Cabal-based flow for creating Mac OS X
applications then I'll try to update the code to work with newer
versions of Cabal.

-- 
-Corey O'Connor


More information about the Haskell-Cafe mailing list