OK, so when I left off last time, I was running into a gruesome link error. I found this Stack Overflow thread and the first accepted answer fixed the problem. However, it seems that the answer may be to avoid MacPorts versions of the libraries I need. So I'm going to attempt to clean that all out and use Homebrew. So, first:
sudo port -fp uninstall --follow-dependents installed
And then I'm manually cleaning out some of the stuff mentioned in this article.
Next, I'm removing this from my .profile (hey, I'm so pleased that it is clearly marked!
# MacPorts Installer addition on 2013-07-16_at_11:57:13: adding an appropriate PATH variable for use with MacPorts. export PATH=/opt/local/bin:/opt/local/sbin:$PATH # Finished adapting your PATH environment variable for use with MacPorts.
Now to install Homebrew:
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
I ran brew doctor and wow, I have a mountain of warnings. I got rid of most of them except for several about "unbrewed" things -- static libraries, .la files, and dylibs in /usr/local/lib. I get a warning about MacGPG2 but that seems to be fixed by upgrading to the current version. So now I'm trying cabal install --reinstall gtk, and I get:
Configuring gtk-0.12.4... setup: The pkg-config package gthread-2.0 is required but it could not be found.
And so, attempting to follow the directions here:
brew install glib cairo gtk gettext fontconfig
...and that actually crashes. I get "confest cannot be opened because of a problem." In the console log:
Process: conftest  Path: /private/tmp/*/conftest Identifier: conftest Version: 0 Code Type: X86-64 (Native) Parent Process: sh  User ID: 501 Date/Time: 2013-07-16 15:42:18.117 -0400 OS Version: Mac OS X 10.8.4 (12E55) Report Version: 10 Crashed Thread: 0 Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000002, 0x0000000000000000 Application Specific Information: dyld: launch, loading dependent libraries Dyld Error Message: Library not loaded: /usr/local/lib/libintl.8.dylib Referenced from: /private/tmp/*/conftest Reason: no suitable image found. Did find: /usr/local/lib/libintl.8.dylib: no matching architecture in universal wrapper /usr/local/lib/libintl.8.dylib: no matching architecture in universal wrapper
And I get an error about "GLib requires a 64 bit type." I also had to do some manual clean-out of some files that had the wrong permissions and were interfering with installing pkgconfig. I found a number of people reporting this problem, but none of the solutions they outlined seemed to work for me. So... what else can I try?
OK! Deep sigh... let's try this!
Pauls-Mac-Pro:Downloads paul$ sh ./gtk-osx-build-setup.sh Checking out jhbuild (07b5a7d) from git... Cloning into 'jhbuild'... remote: Counting objects: 37027, done. remote: Compressing objects: 100% (14715/14715), done. remote: Total 37027 (delta 28610), reused 28612 (delta 22178) Receiving objects: 100% (37027/37027), 7.27 MiB | 2.27 MiB/s, done. Resolving deltas: 100% (28610/28610), done. Switched to a new branch 'stable' Patch is empty. Was it split wrong? If you would prefer to skip this patch, instead run "git am --skip". To restore the original branch and stop patching run "git am --abort". Installing jhbuild... gnome-autogen.sh not available yelp-tools not available Configuring jhbuild without autotools Now type `make' to compile jhbuild Installing jhbuild configuration... Installing gtk-osx moduleset files... PATH does not contain /Users/paul/.local/bin, it is recommended that you add that. Done.
Ummm... OK, wow, that installed source in my home directory build tools in a hidden directory (prefaced with a period) under my home directory. There are warning notes about how the build process conflicts with MacPorts and fink. There's also a note that says "Note: jhbuild requires Python 2.5 to unpack tar files" (of course it does... that's the simplest and most system-compatible way to unpack tar files, right?) Ugh. Anyway... in ~/Source/jhbuild I type ~/.local/bin/jhbuild bootstrap and it builds about a bazillion things including cmake. (Talk amongst yourselves, this is going to take a while... time for another snack...)
That seemed to work. And so: ~/.local/bin/jhbuild build meta-gtk-osx-bootstrap and ~/.local/bin/jhbuild build meta-gtk-osx-core. Somewhat to my shock, everything succeeded! I tried to build gimp, but that failed with "we require Pango with the optional support for Cairo compiled in," and I don't want to go too far down that rabbit hole, so I gave up on that. So let's see if I can make that work with GHC. The next step is package-config. Which requires glib. Ummm, wait a minute... oh, crap. That's still broken with homebrew. Ummm. What about package-config from MacPorts, which the instructions for GTK OSX warned me about? Sure, let's try it, what the hell... after all, I've wasted nearly a full day already... so, sudo port selfupdate, sudo port install pkg-config... that seemed to work. So then we download the Gtk2HS tarball... ummm, the link from the instructions is broken. Ummm... from SourceForge here... but that version is looking much older than the one described here. I'm getting a bad feeling about this. But anyway... 0.10.1 it is! Configure away!
checking for pkg-config... /opt/local/bin/pkg-config checking pkg-config is at least version 0.9.0... yes checking for GLIB... no configure: error: The development files for the glib-2.x library were not found. Perhaps you need to install glib or glib-devel
Huh. Well. It's just about the end of my work day; I've got to go downstairs and help my wife get dinner ready. Ummm. So! I hope you've enjoyed this tutorial on how to use the GTK GUI library in Haskell! Please join me next time when I perform brain surgery on myself using a hacksaw, a folding mirror, and a bottle of Scotch!