Hi John,

Thanks for these detailed directions. I port-installed gtkglext with +universal and +quartz, and then cabal-install a bunch the gtk-related 0.12.1 Haskell packages you mention, plus gtkglext. Then I tried the first sample program at http://www.muitovar.com/gtk2hs/chap2.html in ghci, and I got the following error message:

Loading package cairo-0.12.1 ... can't load .so/.DLL for: Cairo (dlopen(/Library/Frameworks/Cairo.framework/Resources/dev/lib/libCairo.dylib, 9): no suitable image found.  Did find:
    /Library/Frameworks/Cairo.framework/Resources/dev/lib/libCairo.dylib: mach-o, but wrong architecture)

I'm using GHC 7.0.3 from the Haskell Platform (HP), on Mac OS 10.6.8. I think the HP was 32-bit only.

I'm surprised to see /Library/Frameworks/... instead of /opt/lib/... .

Any suggestions?

  - Conal

On Mon, Oct 3, 2011 at 2:37 AM, John Lato <jwlato@gmail.com> wrote:
> From: Tom Murphy <amindfv@gmail.com>
>
> Hi *,
>     I really want to install gtk2hs but I've been putting major time into
> learning Haskell for 1.5 years now, and trying to install gtk2hs for most of
> that time, and I still haven't been able to. I'm not a novice.
>     Are people somewhere installing this successfully? Before Hac Phi, I
> had never seen a fully-functional, non-trivial GUI app in Haskell. My
> installs don't usually fail, so is this the type of package where everyone's
> install fails?
>
> I'm on OSX, 10.6. Pretty clean, new version of Haskell Platform.
>
> I tried cabal-installing it. That had several build errors including
> troubles installing pkg-config. If these details are relevant, I'll
> replicate and paste them here.
>
> Here's my latest MacPorts error:
>
>    $ sudo port install gtk2hs
>    Error: Cannot install gtk2hs for the arch(s) 'i386 x86_64' because
>    Error: its dependency ghc is only installed for the arch 'x86_64'
>    Error: and does not have a universal variant.
>    Error: Unable to execute port: architecture mismatch
>
> Can anyone provide me with a step-by-step guide to installing gtk2hs _which
> includes what to do if a step fails_?

There are a few step-by-step guides on the gtk2hs wiki, but they don't
include what to do when a step fails, and they also don't cover every
possible option.  This reminds me, I meant to update the wiki on this.
 I can't do it until I get home unfortunately.

The reason this is tricky is because there are a lot of different
configurations you may want to use:

1.  Macports gtk2, gtk2hs, and ghc (both X11 and Quartz variants)
2.  Macports gtk2, with standalone/HP/user-compiled ghc  and gtk2hs
(X11 and Quartz variants)
3.  gtk-osx gtk2
4.  Homebrew gtk2 (variants?  I haven't used it)

Since you already have both the Haskell Platform and macports, you
want option 2.  Trying to "port install gtk2hs" would give you two
parallel ghc installs, which is really not recommended.  I usually
would suggest the Quartz variant, but there are various other Macports
gtk2hs addons that only work with X11.  The choice is up to you.

For the quartz variant, here the steps:

1.  Install gtk2

> sudo port install gtk2 +quartz +no_x11

If this fails, you'd probably need to either ask on a macports list,
or possibly try either the X11 variant or homebrew.

2.  install gtk2hs.  For right now you should use the 0.12.1
pre-release packages as detailed in
http://projects.haskell.org/gtk2hs/archives/2011/09/07/gtk2hs-0121-pre-release-packages-available/,
that is:

> cabal install http://code.haskell.org/~duncan/gtk2hs/gtk2hs-buildtools-0.12.1.tar.gz  --extra-lib-dir=/usr/lib
> cabal install http://code.haskell.org/~duncan/gtk2hs/glib-0.12.1.tar.gz http://code.haskell.org/~duncan/gtk2hs/gio-0.12.1.tar.gz http://code.haskell.org/~duncan/gtk2hs/pango-0.12.1.tar.gz http://code.haskell.org/~duncan/gtk2hs/cairo-0.12.1.tar.gz http://code.haskell.org/~duncan/gtk2hs/gtk-0.12.1.tar.gz --extra-lib-dir=/usr/lib -fhave-quartz-gtk

(that's only two lines)

Note the added "--extra-lib-dir=/usr/lib" at the end of each line.
This is to get around incompatibilities between Macports libiconv and
the system libiconv.  You also need to tell cabal that you're using
the quartz-based gtk.

If this fails, come back to this list with the error message.  If it's
a problem with libiconv, the best solution is to manually compile ghc
so it uses the macports iconv, but you may be able to hack around it
some other way, either by deactivating the macports libiconv or
something more nefarious.

If you want to try the X11-based gtk, do this instead:

> sudo port install gtk2

> cabal install http://code.haskell.org/~duncan/gtk2hs/gtk2hs-buildtools-0.12.1.tar.gz  --extra-lib-dir=/usr/lib
> cabal install http://code.haskell.org/~duncan/gtk2hs/glib-0.12.1.tar.gz http://code.haskell.org/~duncan/gtk2hs/gio-0.12.1.tar.gz http://code.haskell.org/~duncan/gtk2hs/pango-0.12.1.tar.gz http://code.haskell.org/~duncan/gtk2hs/cairo-0.12.1.tar.gz http://code.haskell.org/~duncan/gtk2hs/gtk-0.12.1.tar.gz --extra-lib-dir=/usr/lib


John L.

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Gtk2hs-users mailing list
Gtk2hs-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gtk2hs-users