Personal tools

WxHaskell/Cygwin

From HaskellWiki

< WxHaskell(Difference between revisions)
Jump to: navigation, search
(imported via pandoc)
m (WxHaskell/Building on Cygwin moved to WxHaskell/Cygwin)

Revision as of 20:05, 5 August 2008

1 Unix on Windows

To build wxHaskell on windows, you need the cygwin environment to provide essential unix tools necessary to run configure and make, i.e. sh, test, sed, gnu make etc. The cygwin environment provides these tools on windows and these notes describe how to properly install these tools. To compile wxWidgets properly without using Microsoft Visual C++, you also need to install the mingw compiler, as described in the section after installing cygwin. Please note that the compilation of wxWidgets also works without the mingw compiler, but all programs linked with it will fail mysteriously!

2 Install Cygwin

Download the setup program from the cygwin site. When prompted for the packages to install, click also on the Devel and Archive node until they show install (instead of default).

After installation, you need to set a few environment variables. In the following description you should replace the variable $cygwin with your cygwin installation directory (c:\cygwin by default). Set your local environment variables (via start/settings/control panel/system/advanced/environment variables) to the following values:

  • Add the following directories to your PATH: $cygwin\bin and $cygwin\usr\local\lib. On my system this looks like:
    PATH = %PATH%;c:\programs\cygwin\bin;c:\programs\cygwin\usr\local\lib;...
  • Set SHELL to $cygwin\bin\sh.
  • Set MAKE_MODE to UNIX.
  • Set HOME to your preferred home directory, for example: c:\bgates.

Next, we need to ensure that the default shell is bash. Go to the $cygwin/bin directory and rename sh.exe to sh-org.exe. Next, make a copy of bash.exe and name it sh.exe.

We also set some default settings for bash. Create a file .bashrc in your home directory with the following lines:

export CVS_RSH=ssh
export PS1='\[\033[1;31m\]\w\$ \[\033[0m\]'
export PATH=$PATH:/usr/local/bin:.

Finally, you can start a bash command prompt, either via the cygwin icon or by typing bash on the windows command line. To access the c: drive conveniently from the bash command prompt, you can mount the /c directory. You only have to do this once:

> mount c: /c

From now on, you can access the c: drive via /c, for example: cd /c/windows

Cygwin make 3.81 is no more recognizing the DOS style paths. You need to install a 3.80 version that you can get from paracoda. Once your cygwin installation is working, you can install the older make with:

cd /
tar xjf /cygdrive/c/where-your-download-is/make-3.80-1.tar.bz2
bin/make.exe --version

WARNING : It will override the 3.81 make

3 Installing Mingw

In order to compile dynamic link libraries that should work with GHC, we also need the minimalist gnu compiler, called mingw. Compiling with this compiler has the extra advantage that the resulting executables or no longer dependent on the cygwin dll.

Download the latest compiler from the mingw site. There are a lot of packages available but you only need the MinGW package.

After installation, you still need to adapt the cygwin environment in order to use the mingw compiler by default. In the following description, you should replace the $mingw variable with the mingw installation directory (c:\mingw by default).

  • Add the $mingw/bin directory to the start of your PATH environment variable. It is important that it comes before the $cygwin/bin directory. On my system this looks like:
    PATH = %PATH%;c:\programs\mingw\bin;c:\programs\cygwin\bin;...
  • Edit the file $cygwin/etc/profile and add the $mingw/bin directory to the exported PATH. You should use a unix style directory name. On my system this looks like:
    export PATH="/c/programs/mingw/bin:/usr/local/bin:/usr/bin:/bin:$PATH"

To see if your installation was succesfull, you should retrieve the version of the C compiler and see if the result contains the word mingw:

~$gcc --version
gcc.exe (GCC) 3.2 (mingw special 20020817-1)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

In constrast, if you have done something wrong, you would see something like:

~$/c/programs/cygwin/bin/gcc --version
gcc (GCC) 3.2 20020927 (prerelease)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.