Difference between revisions of "GHC under Wine"

From HaskellWiki
Jump to: navigation, search
m (GHCUnderWine moved to GHC under WINE)
(Code that uses gtk2hs: Don't mention a problem that is not caused by gtk2hs in fact)
 
(22 intermediate revisions by 7 users not shown)
Line 1: Line 1:
GHC runs fairly well under wine. Here's a guide on how to get it working.
 
  +
[[Category:GHC]]
  +
[[Category:How to]]
  +
[[Category:OS]]
  +
[[GHC]] runs flawlessly under Wine. Here's a guide on how to get it working.
  +
==Installation==
  +
First, get the latest stable version of Wine from your distribution's repository, or from http://www.winehq.com/site/download.
  +
For Mac users, WineBottler works well.
   
Firstly get the letest version of wine from http://www.winehq.com/site/download and install it.
+
Next, grab the latest [[Windows]] version of Haskell Platform from http://www.haskell.org/platform/windows.html
  +
Installing Haskell is as simple as typing: <code>wine HaskellPlatform-2012.4.0.0-setup.exe</code>
   
Next, grab the latest windows version of GHC from http://haskell.org/ghc/download.html
 
  +
Once this is all done, you should be good to start using GHC.
   
I used the precompiled version of ghc. It's distributed using MSI which can pose a small problem for wine. Luckily, work has been done on developing a native version of MSI for wine. Get it at http://wiki.winehq.org/NativeMsi and follow the instructions to install it.
 
  +
==Testing==
   
Now go to the directory where you've put your download of ghc. install it:
 
  +
Create a simple haskell program to compile. Hello World examples are good. Try compiling it:<br/>
<code>wine msiexec.exe /i ghc-VERSION.msi</code>
 
  +
<code><pre>$ WINEDEBUG=-all wine ghc --make hello.hs
  +
[1 of 1] Compiling Main ( hello.hs, hello.o )
  +
Linking ...
  +
</pre></code>
   
This should start up the installer and walk you through the installation.
 
  +
<code><pre>$ wine hello
  +
Hello, world!
  +
</pre></code>
   
Once it's all done, you should be good to start using GHC. You might want to add GHC to your path. To do this fire up regedit:<br/>
+
If it all works well then you should be able to compile your Haskell programs for windows with GHC on Wine.
<code>wine regedit</code><br/>
 
and go to <code>HKEY_LOCAL_MACHINE->System->CurrentControlSet->Control->Session Manager->Environment->Path</code> and add GHC's installation to the pathlist. It will probably be something like <code>C:\ghc\ghc-VERSION\bin</code>
 
   
Now test it.
 
  +
If you encounter specific, reproducible issues that are present in the latest release of wine you should file a bug report with the Wine project http://bugs.winehq.org (so long as one doesn't already exist for the issue)
   
Create a simple haskell program to compile. Hello World examples are good. Try compiling it:<br/>
 
  +
== Known problems ==
<code><pre>$ wine ghc -o hello --make HelloWorld.hs
 
Chasing modules from: HelloWorld.hs
 
Compiling Main ( HelloWorld.hs, HelloWorld.o )
 
fixme:msvcrt:MSVCRT__sopen : pmode 0x01b6 ignored
 
fixme:msvcrt:MSVCRT__sopen : pmode 0x01b6 ignored
 
Linking ...
 
Wine exited with a successful status</pre></code>
 
   
And try running it:
 
  +
* MSYS does not integrate with MinGW correctly - [http://bugs.winehq.org/show_bug.cgi?id=15949 See Wine bug 15949]
  +
* removeDirectoryRecursive did not work correctly prior to wine-1.1.4-538-g2e8dec4. This most notably broke cabal install. '''Use Wine 1.1.5 or newer.'''
  +
* GHC 6.12.3, Wine 1.2 (from WineBottler) on mac osx leopard: GHC's mingw/bin/gcc.exe exits with a "spawnv failed: errno 2: No such file or directory" error, which breaks cabal install. To work around, replace gcc.exe with a renamed copy of g++.exe, also in that directory ("ghc\bin\mingw> copy g++.exe gcc.exe").
  +
* ghci appears to not work at all on Wine-1.4/Linux-x86, but works OK on Wine-1.7.18/i386, HP 2014.2.0.0 and Ubuntu 12.04.5/x86_64.
   
<code><pre>$ wine hello
 
  +
===Native DLLs===
Hello, world!
 
  +
Wine isn't perfect (yet) but does offer a solution for using native dlls, as an alternative to builtin dlls if certain functions are not implemented or are buggy and not yet fixed. To configure this use winecfg where you can specify settings for the ordering of preferences for loading dlls, Builtin only, Native only, Builtin then Native and Native then Builtin.
Wine exited with a successful status</pre></code>
 
  +
  +
[http://wiki.winehq.org/winetricks winetricks] can be useful for installing common native dlls or software
  +
  +
=== Code that uses gtk2hs ===
  +
  +
First, install GTK from http://www.gtk.org/download/win32.php, according to the instructions from http://www.haskell.org/haskellwiki/Gtk2Hs/Installation#Windows. For compilation of gtk, sometimes (e.g., on Ubuntu 12.04.5/x86_64 with Wine-1.7.18/i386, HP 2014.2.0.0, gtk2hs 0.13 and http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.24/gtk+-bundle_2.24.10-20120208_win32.zip) one needs to use the flag -f-fmode-binary, as described at [https://github.com/gtk2hs/gtk2hs/issues/23#issuecomment-40895472 the following ticket].
   
If it all works well then you should hopefully be able to compile your haskell programs for windows from wine.
 
  +
=== Code that uses Template Haskell ===
   
  +
If the code uses TH together with some external DLLs (e.g., gtk), it may have trouble finding library files, e.g., as reported at [https://ghc.haskell.org/trac/ghc/ticket/9553 #9553]. If so, a workaround similar to the one described in the ticket may help sidestep the problem for now.
   
== Known Problems ==
 
  +
==Debugging==
   
hSetBuffering doesn't seem to work well from terminals. This creates problems with GHCi:
 
  +
You can enable tracing of various components within Wine to aid in debugging issues with Wine by using [http://wiki.winehq.org/DebugChannels Wine Debug Channels].
   
<code><pre>$ wine ghci
 
  +
==External Links==
WARNING: GHCi invoked via 'ghci.exe' in *nix-like shells (cygwin-bash, in particular)
 
doesn't handle Ctrl-C well; use the 'ghcii.sh' shell wrapper instead
 
___ ___ _
 
/ _ \ /\ /\/ __(_)
 
/ /_\// /_/ / / | | GHC Interactive, version 6.4.2, for Haskell 98.
 
/ /_\\/ __ / /___| | http://www.haskell.org/ghc/
 
\____/\/ /_/\____/|_| Type :? for help.
 
   
Loading package base-1.0 ... linking ... done.
 
  +
[http://appdb.winehq.org/objectManager.php?sClass=application&iId=6691 GHC at the Wine AppDB]
<stdin>: hSetBuffering: failed (failed to set buffering)
 
Wine exited with a successful status</pre></code>
 

Latest revision as of 07:28, 13 October 2014

GHC runs flawlessly under Wine. Here's a guide on how to get it working.

Installation

First, get the latest stable version of Wine from your distribution's repository, or from http://www.winehq.com/site/download. For Mac users, WineBottler works well.

Next, grab the latest Windows version of Haskell Platform from http://www.haskell.org/platform/windows.html Installing Haskell is as simple as typing: wine HaskellPlatform-2012.4.0.0-setup.exe

Once this is all done, you should be good to start using GHC.

Testing

Create a simple haskell program to compile. Hello World examples are good. Try compiling it:

$ WINEDEBUG=-all wine ghc --make hello.hs
[1 of 1] Compiling Main             ( hello.hs, hello.o )
Linking ...
$ wine hello
Hello, world!

If it all works well then you should be able to compile your Haskell programs for windows with GHC on Wine.

If you encounter specific, reproducible issues that are present in the latest release of wine you should file a bug report with the Wine project http://bugs.winehq.org (so long as one doesn't already exist for the issue)

Known problems

  • MSYS does not integrate with MinGW correctly - See Wine bug 15949
  • removeDirectoryRecursive did not work correctly prior to wine-1.1.4-538-g2e8dec4. This most notably broke cabal install. Use Wine 1.1.5 or newer.
  • GHC 6.12.3, Wine 1.2 (from WineBottler) on mac osx leopard: GHC's mingw/bin/gcc.exe exits with a "spawnv failed: errno 2: No such file or directory" error, which breaks cabal install. To work around, replace gcc.exe with a renamed copy of g++.exe, also in that directory ("ghc\bin\mingw> copy g++.exe gcc.exe").
  • ghci appears to not work at all on Wine-1.4/Linux-x86, but works OK on Wine-1.7.18/i386, HP 2014.2.0.0 and Ubuntu 12.04.5/x86_64.

Native DLLs

Wine isn't perfect (yet) but does offer a solution for using native dlls, as an alternative to builtin dlls if certain functions are not implemented or are buggy and not yet fixed. To configure this use winecfg where you can specify settings for the ordering of preferences for loading dlls, Builtin only, Native only, Builtin then Native and Native then Builtin.

winetricks can be useful for installing common native dlls or software

Code that uses gtk2hs

First, install GTK from http://www.gtk.org/download/win32.php, according to the instructions from http://www.haskell.org/haskellwiki/Gtk2Hs/Installation#Windows. For compilation of gtk, sometimes (e.g., on Ubuntu 12.04.5/x86_64 with Wine-1.7.18/i386, HP 2014.2.0.0, gtk2hs 0.13 and http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.24/gtk+-bundle_2.24.10-20120208_win32.zip) one needs to use the flag -f-fmode-binary, as described at the following ticket.

Code that uses Template Haskell

If the code uses TH together with some external DLLs (e.g., gtk), it may have trouble finding library files, e.g., as reported at #9553. If so, a workaround similar to the one described in the ticket may help sidestep the problem for now.

Debugging

You can enable tracing of various components within Wine to aid in debugging issues with Wine by using Wine Debug Channels.

External Links

GHC at the Wine AppDB