Showing posts with label mac. Show all posts
Showing posts with label mac. Show all posts

Friday, March 30, 2007

More on Gtk2Hs on Mac Os X

It turns out that the problem with Gtk2Hs was not related at all to GMP or OS X frameworks. The issue is related to ticket #957 and libraries not in the default search path. The problem is fixed by passing the flags '-L/opt/local/lib -I/opt/local/include' to ghc when compiling a Haskell module that uses Gtk2Hs. The right thing to do, copied from the MacPorts book, is to edit your ghc driver (mine lives at /usr/local/bin/ghc) and add these flags there:

Contents of my /usr/local/bin/ghc file:
GHCBIN="/usr/local/lib/ghc-6.7.20070328/ghc-6.7.20070328";
TOPDIROPT="-B/usr/local/lib/ghc-6.7.20070328";
# Mini-driver for GHC
exec $GHCBIN $TOPDIROPT ${1+"$@"} -L/opt/local/lib -I/opt/local/include

Wednesday, March 07, 2007

Gtk2Hs on Mac Os

Omegagb-0005

It all started with the Omega Gameboy Emulator written in Haskell. I got interested by the optimization challenge, it's a cool project after all, even though Haskell is not the most appropriate choice of a language. As a matter of fact I've never been a low-level guy, a systems programmer, but this project had its allure. After having played with the Universal Machine VM this summer during the ICFP contest, I found that I could understand the code very quickly.

After a few days hacking on Omega (it turns out that of the two alternative implementations of the CPU, the fast one was half-coded only, so I wasted a lot of time trying to debug it until I found this out), I got the unstoppable desire of seeing the emulator in action. I had been trying to avoid this, because I knew that setting up Gtk2hs on my Mac Os X86 would be a nightmare, but I just couldn't let go.

So here go my findings. These apply to the current release of Gtk2Hs, that is 0.9.11. I installed gtk2 via MacPorts, and hand compiled Gtk2Hs.

First, home compiled versions of GHC won't work. Gtk2Hs itself will make and install fine, but the helloworld demo will die with a "bus error". GDB is pretty useless to debug the problem. But someone in #haskell told me that MacPorts GHC would work, though he didn't know why. I tested this and he was right. So I digged into the MacPort install script for GHC, and it seemingly has to do with treating GMP as a lib instead of as a framework.
So this is what I found. GHC has a section in the configure.ac file to look for a GMP framework and use that. MacPorts installs GMP as a lib, and since all MacPorts ports try and succeed in eating their own food, the GHC port includes a patch to teach the configure script to use their GMP lib, and ignore any framework.

I don't really understand how frameworks are supposed to work in Mac Os, so I don't know if this makes any sense at all, but now my home compiled GHC is able to compile Gtk2Hs and Haskell code using Gtk, and everything works. I guess it should be possible to manually apply the patch at the ghc port, but I haven't tested it; I did my changes by hand to my package.conf file.

UPDATE: The real fix is given in a later post

Tuesday, August 01, 2006

Feather by feather

I bought me a white Macbook a few weeks ago and have been loving it since the first day. This is my first Apple box and I was a bit afraid that the transition would be time consuming, but I have actually enjoyed it.
Some articles I recommend for tech-savvy people who are in the same situation - Macs are taking over the world nowadays - is the awesome Ars Technica collection of Mac Os reviews.
Even though this has been a great experience and I am loving Mac Os - the hardware is good too, but nothing gets close to a Thinkpad - the system feels very slow most of the time. I use to have several applications running - Emacs, Mail, iTunes, Firefox, Terminal.App, Preview, Colloquy, Skype... - and a perennial ghc compilation process. I'm not sure if this is solely because of the limited amount of RAM the Macbook has (512 mb) or if this has to do with Mac Os 'universal cache'. I say this because it is especially noticeable when I launch a compilation session, often the system becomes totally unuseable - I cannot even type in a console-.

So a major upgrade was in order. A new 7200 rpm hard drive and two 1gb sticks are arriving tomorrow, and I am getting ready for the migration. Sadly I can't use Tiger shiny Migration Assistant to help me, since it requires two Macs and I only have one :S

I'd loke to minimize the time used to install and setup the new hard drive, but also would like to do it from scratch in order to fix the beginner mistakes I have fall in, which include:
  • installing Stuffit, which is a PowerPC binary, will screw all the file associations for archive types
  • xompletely messy iTunes library
  • too many unix packages installed all around. I have used both fink and Darwin Ports, and it seems that a lot of hard drive space is wasted in overlapping base packages. Heck, I even went as far as to compiling amaRoK with fink (and all the base packages it requires!)
  • messy ghc installations all around
  • installing several softwares I didn't end up using
The list below is a self note of all the things I have installed and I want to keep:
  • Carbon Emacs (my .emacs sets up Haskell mode, hippie-completion and a few other keystrokes)
  • Darcs + Darcsweb + setup my httpd
  • of course Firefox. Sure, I like the looks of Camino, but it is not clear to me why would I want to sacrifice all the available Firefox extensions
    • Google Notebook + Google Sync + delicious Complete
  • Missing Sync (demo). Otherwise, iCal will be useless for me.
  • Colloquy
  • Adium (with this fix)
  • Skype (webcam beta version)
  • Dashboard plugins:
    • Wikipedia
    • Sing that itune
    • laTele
    • cloudLicious
    • Airport Radar
  • Spotlight plugins
  • iTunes plugins
    • Synergy (demo)
    • iScrobbler
    • iTunes Catalog (demo)
  • Textmate (demo)
  • XNJB proved pretty handy to manage my brother's Zen
  • Azureus, DivX
  • Omnigraffle, MindManager (demo)
  • Sleepless
  • TexShop + teTex (via fink)
  • XCode tools + Apple X11
  • Virtue Desktops
  • UnrarX
  • rdekstop (via port)
  • Chicken of the vnc
  • subversion (via port)
  • Parallels -unbearably slow with this little memory-. I only need it to tinker with Visual Haskell
  • MacPython
  • Alarm Clock

That's all, and that's enough.
This time the tribute is for Smog.