1
votes

Has anyone succeeded in installing gtk2hs on Windows? I am using Haskell Platform 7.10.2a on Windows 10, both 64-bit, and tried running "cabal install gtk3", but it failed on the gio package with error message:

gcc.exe: error: unrecognized option '-pthread'

(Edit extra note: next line of error message below)

compiling dist\build\System\GIO\File\FileAttribute_hsc_make.c failed (exit code 1)

It appears that the gcc in the mingw subfolder in the Haskell Platform package is a little outdated. Is there any way to update this subfolder? The only clue I found on the Internet is the link below, which does not seem to offer any solution:

https://ghc.haskell.org/trac/ghc/ticket/10726

(Edit: version of gcc seems unrelated. '-pthread' switch appears to be invalid for gcc when run under Windows, it's only valid in Linux, see this link, but I have no idea why GHC/GTK3 is using -pthread and no idea how to change this to -mthread http://mingw-users.1079350.n2.nabble.com/pthread-vs-mthreads-td7114500.html)

Before running cabal, I installed GTK+ 3.18.0.1 on Windows using MSYS2.

I have installed gtk2hs on Linux easily with no issues at all.

1
Im pretty sure you can't change the mingw that came with ghc or it will break, but you should just build gtk with a different C compiler (one that will support pthreads on windows ... not sure if that's a thing).user2407038
Sorry I wasn't clearer earlier, the gcc issue is not on GTK+ itself, but on Cabal trying to compile a .hsc file in the Gtk2Hs package. When compiling a .hsc file, gcc is needed, see: downloads.haskell.org/~ghc/latest/docs/html/users_guide/… I found online that both MinGHC and Stack use MSYS, so I thought maybe they could solve the problem of gcc version by updating gcc from inside MSYS, but no luck so far, still trying.Rascal the Raccoon

1 Answers

2
votes

Update: Also got GTK3 (bundle from below) running a Windows 10 64 bit device. The additional step I had to accomplish was to include the libintl.def and libintl.dll.a from an older bundle into the lib folder. I obtained those two files from a GTK2.x bundle, i.e. https://download.gnome.org/binaries/win64/gtk+/2.22/gtk+-bundle_2.22.1-20101229_win64.zip.mirrorlist, otherwise cabal was complaining about the missing C library intl. To sum up:

1) Obtain a GTK3 x64 bundle from the link http://www.tarnyko.net/dl/gtk.htm.

2) Obtain the missing files libintl.def and libintl.dll.a from an older bundle, i.e. GTK2 (link from above) and include them in the lib folder.

3) Install glib first, run cabal install glib. Ensure that you have administrator privileges and GTK3/bin is on your PATH variable. Additionally, you can set LIB and INCLUDE pointing to the GTK/lib and GTK/include folder respectively (might not be necessary).

4) Run cabal install gtk3 finally. You may use the flag --global.

(Tested on Windows 10, 64-Bit, Haskell Platform 8.x)


Installation steps for Windows 7, 64-Bit: (Original Post)

I figured it out how to install GTK3 on Windows7 (64 bit) when running Haskell Platform 7.10.3. Therefor, I had to accomplish following steps:

  1. Download the gtk3 64-bit bundle from http://www.tarnyko.net/dl/gtk.htm (personally I have used the 3.6 version of it)
  2. Download the gtk3 binding https://hackage.haskell.org/package/gtk3 (0.14.5)
  3. Install the dependencies separately. This encompasses the libraries gio, glib and pango (not cairo in my case). (cabal install package-name)
  4. Adjust the gtk3.cabal file. I have removed following lines (all are within 5 lines):
    • if os(darwin) cpp-options: -D__attribute__(A)=
    • -DWIN32 (just that one flag)
    • extra-libraries: kernel32
  5. Adjust the gtk.h file (comes with the gtk3 bundle, include\gtk-3.0\gtk) I have defined following macros BEFORE the include operation of #include :

    define GDK_VERSION_3_0 (G_ENCODE_VERSION (3, 0))

    define GDK_VERSION_MIN_REQUIRED GDK_VERSION_3_0

    define GDK_VERSION_MAX_ALLOWED GDK_VERSION_3_6

    define GDK_DISABLE_DEPRECATION_WARNINGS

  6. Add the path of the MinGW and gtk3 folders bin, include, lib to the PATH variable.

  7. Run cabal install gtk3.cabal
  8. Following tricks also helped me (command line parameters):
    • --gcc-options="C=LANG"
    • --with-gcc="path to gcc.exe"
    • --global

To be honest, this was more luck than knowledge. Took me several hours to find a workaround. I had the same troubles with the gtk2 bindings for haskell. (Installing gtk2hs failure)