Installing Cygwin

MSWin users will need the Cygwin development environment in order to get a local copy of NEURON's Subversion repository and / or compile NEURON from source code.
  1. Go to http://www.cygwin.com and download setup.exe
    To avoid cluttering up my desktop, I made a special directory on my hard drive called c:\installed\cygwin and put cygwin.exe in there.
  2. Run setup.exe as yourself (not as Administrator).
    • Select "Install from Internet".
    • Specify the Root Install Directory to be c:\cygwin
    • Install for "All Users" and set the "Default Text File Type" to be Unix / binary.
    • Specify your preferred Local Package Directory (I chose c:\installed\cygwin). This is where the cygwin installer is going to put a folder that has a long, ugly name. You're not going to want to see this folder on your desktop.
    • Choose a download site that is nearby. ftp sites will probably do faster downloads than http. I chose ftp://ftp.gtlib.gatech.edu
    • Select Packages. Accept the defaults except for the following:
      • Archive--get zip and unzip
      • Devel--change to Install
      • Editors--get what you're familiar with. I chose vim.
      • Net--accept the Default selections, but check to make sure openssl is selected.
        openssh doesn't seem to be necessary.
      • Shells--get rxvt: VT102 terminal emulator for both X and Windows
      In each of these cases, be sure to get the "Bin" (binary), not the "Src" (source).
    • Cygwin Setup may select additional packages to "meet dependencies"; accept the selections.
    • At the last step in installation, the installer asks if you want to
      "Create icon on Desktop" or "Add icon to Start Menu".
      You will not be using these icons, so uncheck the boxes, then click the Finish button.

Configuring Cygwin

Set up an rxvt shortcut

This will be very handy for quickly creating several shell terminals.

  1. Open Windows Explorer, go to c:\cygwin\bin, and create a shortcut to rxvt.exe
    Move this shortcut to your desktop.
  2. Right click on the shortcut icon, select Properties, and change its "Target" string to
        c:\cygwin\bin\rxvt.exe -fg black -bg white -sl 1000 -e bash
    (that "sl" is lower case "SL", not an s followed by the number 1).
    This will give you an rxvt terminal with black text on white background, which runs under the bash shell, and has 1000 lines of scrollable output.
  3. Click on "Apply", then "OK" to close the properties window.

Set up your home directory and bash shell environment

  1. Double click on the rxvt.exe shortcut to open a bash shell window.
    In this window, type
    cd /
    /bin/ls
    
    That should produce the following output:
    Cygwin.bat  Cygwin.ico  bin  cygdrive  etc  lib  proc  sbin  srv  tmp  usr  var
    
  2. Type the following commands:
    /bin/mkdir home
    cd home
    /bin/mkdir yourname
    
    where "yourname" will be the name of your "home" directory under Cygwin.
    There must be no spaces in whatever you choose for "yourname".
  3. Next,
    cd yourname
    
    and use a text editor to create a file called .bashrc that has these contents:
    export PATH=/usr/bin:$PATH
    export HOME=/home/yourname
    export PATH=$HOME/bin:$PATH
    cd
    
    Save the file and close the rxvt window.
  4. Test this by opening Cygwin's rxvt window (rxvt.exe shortcut on desktop!) and executing this command:
    pwd
    
    It should return
    /home/yourname
    
    Close the rxvt window.

Configuring Cygwin

I just installed Cygwin 1.7.7 (latest version as of 2010-12-01) and found that almost zero effort is required to configure it. Specifically, users no longer need to set up an rxvt shortcut, or to set up a home directory and bash shell environment. Instead, simply
  1. copy the "rxvt-native" link to the Desktop from the Cygwin program group in the Start menu
  2. double click on this link. There is NO need to tinker with the "target" of this link.
When you click on rxvt-native for the first time, Cygwin creates the necessary "." config files in your home directory and sets up your environment for you. After it finishes, just execute the command
  echo $PATH
to see the long PATH that Cygwin created. Then try
  pwd
which reveals that you're in /home/name, where name is your MSWin login name.
  ls /cygdrive/c/cygwin/home
will return
  name
which confirms that your Cygwin home directory is in the directory that MSWin knows as c:\cygwin\home

Which makes me wonder: for how long now has Cygwin been capable of doing all these things? I suspect that the answer may be "quite a while."

New and improved is the enemy of good enough

Yesterday (Dec. 8 2010) I installed the latest Cygwin (1.7.1-1) on a different PC, and found that the new version still creates the user's home directory and "dot config files" automatically. However, "rxvt-native" had gone away. Instead, the NEURON program group contained only an icon labeled "Cygwin" that brought up plain old rxvt. I copied this to the desktop and changed the command line associated with it (what MS, with its usual mind-numbing obfuscation, calls the "target string") so that it was identical to the command line for the rxvt-native icon under Cygwin 1.7.1, but no luck--under 1.7.1-1, clicking on my customized icon produced a window that flashed briefly on the screen, only to vanish in less than half a second. That was disappointing, but not disastrous, because changing the "target string" to what NEURON recommends above produced something that works.