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

5 comments:

alex said...
This comment has been removed by a blog administrator.
alex said...
This comment has been removed by a blog administrator.
Anonymous said...

Hi,
I've tried to compile a simple helloworld program with ghc 6.8.2, gtk2hs 0.9.12.1 and it compiles ok. However, when running the application (with X11 already open) it crashes with 'Bus error'. I have tried to use the workarounds you commented (i.e. activating compiler flags) but it still doesn't work .
GDB debugger dumps the following error message:

(gdb) r
Starting program: /Users/claude/Desktop/haskex/hello
Reading symbols for shared libraries ..+.....+...........................................................+++...++.....++++...+++++++++++++ done

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000000
0x015e64c0 in _X11TransWritev ()


Any ideas about it? I cannot find a solution to this problem.

Claude

Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...

I want to quote your post in my blog. It can?
And you et an account on Twitter?