Skip to content

Instantly share code, notes, and snippets.

@cjolowicz
Last active December 29, 2015 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cjolowicz/7739085 to your computer and use it in GitHub Desktop.
Save cjolowicz/7739085 to your computer and use it in GitHub Desktop.
Installing gtk2hs on Mac OS X 10.9
# Install XQuartz
wget http://xquartz.macosforge.org/downloads/SL/XQuartz-2.7.5.dmg
mkdir /Volumes/XQuartz-2.7.5
hdiutil attach -mountpoint /Volumes/XQuartz-2.7.5 XQuartz-2.7.5.dmg
sudo installer -pkg /Volumes/XQuartz-2.7.5/*.pkg -target /
hdiutil detach -mountpoint /Volumes/XQuartz-2.7.5 XQuartz-2.7.5.dmg
rmdir /Volumes/XQuartz-2.7.5
rm XQuartz-2.7.5.dmg
# Install GTK.
brew install gtk
# Install gtk2hs.
cabal install gtk2hs-buildtools
libpath=$(echo /usr/local/opt/*/lib|xargs -n1 printf '%s:')
includepath=$(echo /usr/local/opt/*/include|xargs -n1 printf '%s:')
PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig \
cabal install \
--extra-lib-dirs=$libpath \
--extra-include-dirs=$includepath gtk
# Error:
# Preprocessing library glib-0.12.5.0...
# gtk2hsC2hs: Error in C header file.
#
# /usr/include/dirent.h:140: (column 66) [FATAL]
# >>> Syntax error!
# The symbol `=' does not fit here.
#
# Failed to install glib-0.12.5.0
# Error when PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig/ is omitted:
# Configuring cairo-0.12.5.0...
# setup: Package xcb-shm was not found in the pkg-config search path.
# Perhaps you should add the directory containing `xcb-shm.pc'
# to the PKG_CONFIG_PATH environment variable
# Package 'xcb-shm', required by 'cairo', not found
# Failed to install cairo-0.12.5.0
# Error when --extra-*-dirs options are omitted:
# Configuring glib-0.12.5.0...
# setup: Missing dependency on a foreign library:
# * Missing C library: intl
@songpp
Copy link

songpp commented Jan 8, 2014

I got the same error:

/usr/include/dirent.h:140: (column 66) [FATAL]
#     >>> Syntax error!
#     The symbol `=' does not fit here.

any workaround?

@kmarekspartz
Copy link

Same here.

@aaarbk
Copy link

aaarbk commented Mar 24, 2014

and here

@daliborfilus
Copy link

aaaand here

XCode 5.1, OS X Mavericks

$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix

$ cabal --version
cabal-install version 1.16.0.2
using version 1.16.0 of the Cabal library

# ...
Configuring glib-0.12.5.3...

/var/folders/qh/fcry_js52mzdx2l7zsjbvcz80000gn/T/69063.c:1:12:
     warning: control reaches end of non-void function [-Wreturn-type]
int foo() {}
           ^
1 warning generated.
Building glib-0.12.5.3...
Preprocessing library glib-0.12.5.3...
gtk2hsC2hs: Error in C header file.

/usr/include/dirent.h:140: (column 66) [FATAL]
  >>> Syntax error!
  The symbol `=' does not fit here.

Failed to install glib-0.12.5.3
cabal: Error: some packages failed to install:
cairo-0.12.5.3 failed during the configure step. The exception was:
ExitFailure 1
gio-0.12.5.3 depends on glib-0.12.5.3 which failed to install.
glib-0.12.5.3 failed during the building phase. The exception was:
ExitFailure 1
gtk-0.12.5.6 depends on glib-0.12.5.3 which failed to install.
gtksourceview2-0.12.5.0 depends on glib-0.12.5.3 which failed to install.
leksah-0.8.0.4 depends on glib-0.12.5.3 which failed to install.
leksah-server-0.8.0.5 depends on glib-0.12.5.3 which failed to install.
ltk-0.8.0.6 depends on glib-0.12.5.3 which failed to install.
pango-0.12.5.3 depends on glib-0.12.5.3 which failed to install.

@hughrawlinson
Copy link

here too

@kennethchoe
Copy link

You need gcc 4.8. This worked for me: http://www.haskell.org/haskellwiki/Gtk2Hs/Mac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment